Struct mucell::MuCell [] [src]

pub struct MuCell<T: ?Sized> { /* fields omitted */ }

A cell with the ability to mutate the value through an immutable reference when safe.

Methods

impl<T> MuCell<T>
[src]

Creates a MuCell containing value.

Examples

use mucell::MuCell;

let c = MuCell::new(5);

Consumes the MuCell, returning the wrapped value.

Examples

use mucell::MuCell;

let c = MuCell::new(5);

let five = c.into_inner();

impl<T: ?Sized> MuCell<T>
[src]

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 inside the try_mutate() mutator function. But that’s generally a nonsensical thing to do, anyway, so just be sensible and you’re OK.

Mutably borrows the wrapped value.

Unlike RefCell.borrow_mut, this method lets Rust’s type system prevent aliasing and so cannot have anything go wrong. It is also, in consequence, completely free, unlike RefCell or MuCell.borrow which all have to keep track of borrows at runtime.

Mutate the contained object if possible.

If any immutable references produced by calling borrow() are active, this will return false, not executing the function given.

If there are no immutable references active, this will execute the mutator function and return true.

The mutator function should not touch self (not that it would really make much sense to be touching it, anyway); most notably, you may not call borrow on self inside the mutator, which includes things like the == implementation which borrow the value briefly; while calling try_mutate inside it will just return false, calling borrow will panic.

Trait Implementations

impl<T: ?Sized> Send for MuCell<T> where
    T: Send
[src]

impl<T: ?Sized + PartialEq> PartialEq for MuCell<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: ?Sized + Eq> Eq for MuCell<T>
[src]

impl<T: PartialOrd> PartialOrd for MuCell<T>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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 MuCell<T>
[src]

This method returns an Ordering between self and other. Read more

impl<T: Default> Default for MuCell<T>
[src]

Returns the "default value" for a type. Read more

impl<T: Clone> Clone for MuCell<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Display> Display for MuCell<T>
[src]

Formats the value using the given formatter. Read more

impl<T: Debug> Debug for MuCell<T>
[src]

Formats the value using the given formatter.

impl<T: Octal> Octal for MuCell<T>
[src]

Formats the value using the given formatter.

impl<T: LowerHex> LowerHex for MuCell<T>
[src]

Formats the value using the given formatter.

impl<T: UpperHex> UpperHex for MuCell<T>
[src]

Formats the value using the given formatter.

impl<T: Pointer> Pointer for MuCell<T>
[src]

Formats the value using the given formatter.

impl<T: Binary> Binary for MuCell<T>
[src]

Formats the value using the given formatter.

impl<T: LowerExp> LowerExp for MuCell<T>
[src]

Formats the value using the given formatter.

impl<T: UpperExp> UpperExp for MuCell<T>
[src]

Formats the value using the given formatter.

impl<T> Hash for MuCell<T> where
    T: Hash
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more