Skip to content

Commit

Permalink
Add EphemeralOpaque::defunct().
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Aug 26, 2024
1 parent 5e51f9d commit 4fc0743
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions all-is-cubes/src/inv/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,12 @@ impl<T: ?Sized> EphemeralOpaque<T> {
Self(Some(contents))
}

/// Constructs an [`EphemeralOpaque`] that is already defunct
/// (holds no value).
pub fn defunct() -> Self {
Self(None)
}

/// Get a reference to the value if it still exists.
pub fn try_ref(&self) -> Option<&T> {
self.0.as_deref()
Expand Down

0 comments on commit 4fc0743

Please sign in to comment.