Struct threadalone::ThreadAlone
source · pub struct ThreadAlone<T> { /* private fields */ }Expand description
ThreadAlone is a Sync-maker and Send-maker that allows accessing a value of type T only from the original thread on which the ThreadAlone was constructed.
Refer to the crate-level documentation for a usage example.
Implementations§
source§impl<T> ThreadAlone<T>
impl<T> ThreadAlone<T>
sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Binds a value to the current thread. The wrapper can be sent around to other threads, but no other threads will be able to access the underlying value.
sourcepub fn get_ref(&self) -> Option<&T>
pub fn get_ref(&self) -> Option<&T>
Accesses a reference to the underlying value if this is its original
thread, otherwise None.
sourcepub fn get_mut(&mut self) -> Option<&mut T>
pub fn get_mut(&mut self) -> Option<&mut T>
Accesses a mutable reference to the underlying value if this is its
original thread, otherwise None.
sourcepub fn into_inner(self) -> Option<T>
pub fn into_inner(self) -> Option<T>
Extracts ownership of the underlying value if this is its original
thread, otherwise None.