Ownable

Trait Ownable 

Source
pub trait Ownable {
    type Item;

    // Required methods
    fn take(&mut self) -> TakenGuard<'_, Self, Self::Item>
       where Self: Sized;
    fn read(&self) -> Option<&Self::Item>;
    fn put_back(&mut self, val: Self::Item);
    fn is_available(&self) -> bool;
}
Expand description

Defines the core structure of a Container that holds a value which can be moved out and returned to it Allowing mutation by moving and returning, or simply reading directly from it.

Required Associated Types§

Required Methods§

Source

fn take(&mut self) -> TakenGuard<'_, Self, Self::Item>
where Self: Sized,

Source

fn read(&self) -> Option<&Self::Item>

Source

fn put_back(&mut self, val: Self::Item)

Source

fn is_available(&self) -> bool

Implementors§

Source§

impl<T> Ownable for OwnableCell<T>

Defines a Cell that holds a number, takes and mutates it and then reads from the Cell again.

§Examples

let mut source = OwnableCell::Available(100);
{
    let mut guard = item.take();
    *guard.unwrap() += 100;
}
assert_eq!(200, source.read().unwrap());
Source§

type Item = T