pub struct SingleThreadCell<T> { /* private fields */ }Expand description
A value that can be read and written by only one thread.
Ownership is granted to the first thread that accesses it, first come, first served. Once a thread owns the value, no other thread can read or modify it.
Even though SingleThread<T> implements Sync and Send, it can only be accessed
by the first thread that uses it. Any attempt to access it from a different thread will fail.
Implementations§
Source§impl<T> SingleThreadCell<T>
impl<T> SingleThreadCell<T>
pub const fn new(value: T) -> SingleThreadCell<T>
Trait Implementations§
Source§impl<T> Guarded<T> for SingleThreadCell<T>
impl<T> Guarded<T> for SingleThreadCell<T>
Source§impl<T> GuardedMut<T> for SingleThreadCell<T>
impl<T> GuardedMut<T> for SingleThreadCell<T>
type GuardMut<'a> = RefMut<'a, T> where SingleThreadCell<T>: 'a
Source§fn get_mut<'a>(&'a self) -> <SingleThreadCell<T> as GuardedMut<T>>::GuardMut<'a>
fn get_mut<'a>(&'a self) -> <SingleThreadCell<T> as GuardedMut<T>>::GuardMut<'a>
Can panic on exceptional behavior (ex poisoned mutex)
Source§impl<T> TryGuarded<T> for SingleThreadCell<T>
impl<T> TryGuarded<T> for SingleThreadCell<T>
type Error<'a> = SingleThreadError where SingleThreadCell<T>: 'a
fn try_get<'a>( &'a self, ) -> Result<<SingleThreadCell<T> as Guarded<T>>::Guard<'a>, <SingleThreadCell<T> as TryGuarded<T>>::Error<'a>>
Source§impl<T> TryGuardedMut<T> for SingleThreadCell<T>
impl<T> TryGuardedMut<T> for SingleThreadCell<T>
type Error<'a> = SingleThreadMutError where SingleThreadCell<T>: 'a
fn try_get_mut<'a>( &'a self, ) -> Result<<SingleThreadCell<T> as GuardedMut<T>>::GuardMut<'a>, <SingleThreadCell<T> as TryGuardedMut<T>>::Error<'a>>
impl<T> Send for SingleThreadCell<T>
impl<T> Sync for SingleThreadCell<T>
Auto Trait Implementations§
impl<T> !Freeze for SingleThreadCell<T>
impl<T> !RefUnwindSafe for SingleThreadCell<T>
impl<T> Unpin for SingleThreadCell<T>where
T: Unpin,
impl<T> UnsafeUnpin for SingleThreadCell<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for SingleThreadCell<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
Source§impl<S, T> CastRangeInto<T> for Swhere
T: CastRangeFrom<S>,
impl<S, T> CastRangeInto<T> for Swhere
T: CastRangeFrom<S>,
fn cast_range_into(self) -> T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more