Struct Leaked

Source
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§

Source§

impl<V> Leaked<V>

Source

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§

Source§

impl<V> Deref for Leaked<V>

Source§

type Target = V

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<V> Send for Leaked<V>
where V: Send,

Source§

impl<V> Sync for Leaked<V>
where V: Sync,

Auto Trait Implementations§

§

impl<V> Freeze for Leaked<V>
where V: Freeze,

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.