Struct movecell::MoveCell
[−]
[src]
pub struct MoveCell<T>(_);
A container similar to std::cell::Cell
,
but that also supports not-implicitly-copyable types.
Methods
impl<T> MoveCell<T>
[src]
fn new(value: T) -> MoveCell<T>
Create a new MoveCell
containing the given value.
fn replace(&self, new_value: T) -> T
Return the inner value after replacing it with the given value.
unsafe fn as_unsafe_cell(&self) -> &UnsafeCell<T>
Returns a reference to the underlying UnsafeCell
.
Unsafety
This method is unsafe because UnsafeCell
's field is public.
impl<T: Default> MoveCell<T>
[src]
Convenience methods for when there is a default value.
fn take(&self) -> T
Return the inner value after replacing it with the default value.
fn peek<U, F>(&self, f: F) -> U where F: FnOnce(&T) -> U
Apply a function to a reference to the inner value. The cell’s contents are temporarily set to the default value during the call.
fn clone_inner(&self) -> T where T: Clone
Return a clone of the inner optional value. The cell’s contents are temporarily set to the default value during the clone.
impl<T> MoveCell<Option<T>>
[src]
Convenience methods for when the value happens to be an Option
.
fn map<U, F>(&self, f: F) -> Option<U> where F: FnOnce(&T) -> U
Apply a function to a reference to the inner value if it is Some(_)
.
The cell’s contents are temporarily set to None
during the call.
fn is_some(&self) -> bool
Return whether the inner optional value is Some(_)
.
The cell’s contents are temporarily set to None
during the call.
fn is_none(&self) -> bool
Return whether the inner optional value is None(_)
.
The cell’s contents are temporarily set to None
during the call.
fn and_then<U, F>(&self, f: F) -> Option<U> where F: FnOnce(&T) -> Option<U>
Apply a function to a reference to the inner value if it is Some(_)
.
The cell’s contents are temporarily set to None
during the call.
Trait Implementations
impl<T: Default> Default for MoveCell<T>
[src]
impl<T: Default + Clone> Clone for MoveCell<T>
[src]
The cell’s contents are temporarily set to the default value during the clone.
fn clone(&self) -> MoveCell<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: Default + Debug> Debug for MoveCell<T>
[src]
The cell’s contents are temporarily set to the default value during the formatting.
impl<T: Default + Eq> Eq for MoveCell<T>
[src]
The cell’s contents are temporarily set to the default value during the comparaison.
impl<T: Default + PartialEq> PartialEq for MoveCell<T>
[src]
The cell’s contents are temporarily set to the default value during the comparaison.