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.
Methods
impl<T> SendCell<T>
[src]
fn new(value: T) -> Self
Creates a new SendCell
containing value
.
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.
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)
.
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.
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.
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.
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: Clone> Clone for 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
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for SendCell<T>
[src]
impl<T> From<T> for SendCell<T>
[src]
impl<T: Default> Default for SendCell<T>
[src]
impl<T: PartialEq> PartialEq<SendCell<T>> for SendCell<T>
[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
This method tests for !=
.
impl<T: Eq> Eq for SendCell<T>
[src]
impl<T: PartialOrd> PartialOrd<SendCell<T>> for SendCell<T>
[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
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
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
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
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]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
ord_max_min
)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
ord_max_min
)Compares and returns the minimum of two values. Read more
impl<T: Hash> Hash for SendCell<T>
[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
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more