pub struct Leaked<V> { /* private fields */ }
Expand description
A leaked value from the map.
Similar to Evicted
, this type implements Deref
,
allowing for immutable access to the underlying value.
This type behaves similarly to ManuallyDrop
in that the underlying
value is not dropped if the wrapper is dropped. See leak
for how to
safely drop or take ownership of a leaked value. See into_inner
for details on how to unsafely take ownership of a leaked value.
Implementations
sourceimpl<V> Leaked<V>
impl<V> Leaked<V>
sourcepub fn into_inner(leaked: Self) -> Alias<V>
pub fn into_inner(leaked: Self) -> Alias<V>
Consumes this leaked value, providing the inner aliased value. Note that the aliased value
must be manually dropped via Alias::
drop
, or converted into an
owned value via Alias::
into_owned
.
Examples
use flashmap::{self, Alias, Evicted, Leaked};
let (mut write, read) = flashmap::new::<u32, Box<u32>>();
write.guard().insert(10, Box::new(20));
// Remove and leak the previously inserted value
let leaked: Leaked<Box<u32>> = write.guard()
.remove(10)
.map(Evicted::leak)
.unwrap();
// Extract the inner aliased value
let inner: Alias<Box<u32>> = Leaked::into_inner(leaked);
// Wait until no more readers can access the aliased value
write.synchronize();
// Safety: we called `synchronize` on the write handle of the map the aliased
// value came from, so we are guaranteed that we are the only ones accessing the
// aliased value from this point forward.
let value = unsafe { Alias::into_owned(inner) };
assert_eq!(*value, 20);
Trait Implementations
impl<V> Send for Leaked<V> where
V: Send,
impl<V> Sync for Leaked<V> where
V: Sync,
Auto Trait Implementations
impl<V> RefUnwindSafe for Leaked<V> where
V: RefUnwindSafe,
impl<V> Unpin for Leaked<V> where
V: Unpin,
impl<V> UnwindSafe for Leaked<V> where
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more