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

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

The resulting type after dereferencing.

Dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.