Struct threadbound::ThreadBound
source · pub struct ThreadBound<T> { /* private fields */ }
Expand description
ThreadBound is a Sync-maker and Send-maker that allows accessing a value of type T only from the original thread on which the ThreadBound was constructed.
Refer to the crate-level documentation for a usage example.
Implementations§
source§impl<T> ThreadBound<T>
impl<T> ThreadBound<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
.
Trait Implementations§
source§impl<T: Debug> Debug for ThreadBound<T>
impl<T: Debug> Debug for ThreadBound<T>
source§impl<T: Default> Default for ThreadBound<T>
impl<T: Default> Default for ThreadBound<T>
impl<T: Copy> Send for ThreadBound<T>
impl<T> Sync for ThreadBound<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for ThreadBound<T>where T: RefUnwindSafe,
impl<T> Unpin for ThreadBound<T>where T: Unpin,
impl<T> UnwindSafe for ThreadBound<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more