Struct send_cell::SendCell [−][src]
pub struct SendCell<T> { /* fields omitted */ }
An immutable memory location that implements Send
for types that do not implement it
Enforcing safety with regard to the Send
trait happens at runtime instead of compile time.
Accessing the contained value will call panic!
if happening from any thread but the thread on
which the value was created on. The SendCell
can be safely transferred to other threads.
Warning
Any other usage from a different thread will lead to a panic, i.e. using any of the traits
implemented on SendCell
like Eq
.
Calling drop
on a SendCell
or otherwise freeing the value from a different thread than the
one where it was created also results in a panic.
Methods
impl<T> SendCell<T>
[src]
impl<T> SendCell<T>
pub fn new(value: T) -> Self
[src]
pub fn new(value: T) -> Self
Creates a new SendCell
containing value
.
pub fn into_inner(self) -> T
[src]
pub fn into_inner(self) -> T
Consumes the SendCell
, returning the wrapped value.
Panics
Panics if called from a different thread than the one where the original value was created.
pub fn try_into_inner(self) -> Result<T, Self>
[src]
pub fn try_into_inner(self) -> Result<T, Self>
Consumes the SendCell
, returning the wrapped value if successful.
The wrapped value is returned if this is called from the same thread as the one where the
original value was created, otherwise the SendCell
is returned as Err(self)
.
pub fn get(&self) -> &T
[src]
pub fn get(&self) -> &T
Immutably borrows the wrapped value.
Multiple immutable borrows can be taken out at the same time.
Panics
Panics if called from a different thread than the one where the original value was created.
pub fn try_get(&self) -> Option<&T>
[src]
pub fn try_get(&self) -> Option<&T>
Tries to immutably borrow the wrapped value.
None
is returned if called from a different thread than the one where the original value
was created.
Multiple immutable borrows can be taken out at the same time.
pub fn borrow(&self) -> Ref<T>
[src]
pub fn borrow(&self) -> Ref<T>
Immutably borrows the wrapped value.
The borrow lasts until the returned Ref
exits scope. Multiple immutable borrows can be
taken out at the same time.
Panics
Panics if called from a different thread than the one where the original value was created.
pub fn try_borrow(&self) -> Option<Ref<T>>
[src]
pub fn try_borrow(&self) -> Option<Ref<T>>
Tries to immutably borrow the wrapped value.
None
is returned if called from a different thread than the one where the original value
was created.
The borrow lasts until the returned Ref
exits scope. Multiple immutable borrows can be
taken out at the same time.
Trait Implementations
impl<T> From<T> for SendCell<T>
[src]
impl<T> From<T> for SendCell<T>
impl<T: Default> Default for SendCell<T>
[src]
impl<T: Default> Default for SendCell<T>
impl<T: Clone> Clone for SendCell<T>
[src]
impl<T: Clone> Clone for SendCell<T>
fn clone(&self) -> SendCell<T>
[src]
fn clone(&self) -> SendCell<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for SendCell<T>
[src]
impl<T: Debug> Debug for SendCell<T>
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl<T: PartialEq> PartialEq<SendCell<T>> for SendCell<T>
[src]
impl<T: PartialEq> PartialEq<SendCell<T>> for SendCell<T>
fn eq(&self, other: &Self) -> bool
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<T: Eq> Eq for SendCell<T>
[src]
impl<T: Eq> Eq for SendCell<T>
impl<T: PartialOrd> PartialOrd<SendCell<T>> for SendCell<T>
[src]
impl<T: PartialOrd> PartialOrd<SendCell<T>> for SendCell<T>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Ord> Ord for SendCell<T>
[src]
impl<T: Ord> Ord for SendCell<T>
fn cmp(&self, other: &Self) -> Ordering
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<T: Hash> Hash for SendCell<T>
[src]
impl<T: Hash> Hash for SendCell<T>
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T> Send for SendCell<T>
[src]
impl<T> Send for SendCell<T>