Struct mitochondria::MoveCell [] [src]

pub struct MoveCell<T>(_);

A mutable memory location that clones its contents on retrieval.

Methods

impl<T> MoveCell<T>
[src]

fn new(value: T) -> Self

Creates a new MoveCell containing the given value.

Example

use mitochondria::MoveCell;

let c = MoveCell::new("Hello cytosol!".to_owned());

fn replace(&self, value: T) -> T

Replaces the value of this cell, returning the old one.

Example

use mitochondria::MoveCell;

let c = MoveCell::new("Hello lysosome!".to_owned());

let greeting = c.replace("Goodbye!".to_owned());

impl<T> MoveCell<T>
[src]

fn set(&self, value: T)

Sets the value of this cell, dropping the old one.

Example

use mitochondria::MoveCell;

let c = MoveCell::new("Hello vacuole!".to_owned());

c.set("Hello cytoskeleton!".to_owned());

impl<T: Default> MoveCell<T>
[src]

fn take(&self) -> T

Returns the value in this cell, replacing it by T::default.

Example

use mitochondria::MoveCell;

let c = MoveCell::new(vec!["vacuole", "cytoskeleton"]);

assert_eq!(c.take(), &["vacuole", "cytoskeleton"]);
assert_eq!(c.take(), &[] as &[&str]);