[][src]Struct merk::owner::Owner

pub struct Owner<T> { /* fields omitted */ }

A container type which holds a value that may be temporarily owned by a consumer.

Implementations

impl<T> Owner<T>[src]

pub fn new(value: T) -> Owner<T>[src]

Creates a new Owner which holds the given value.

pub fn own<F: FnOnce(T) -> T>(&mut self, f: F)[src]

Takes temporary ownership of the contained value by passing it to f. The function must return a value of the same type (the same value, or a new value to take its place).

Example

let mut owner = Owner::new(SomeType());
owner.own(|value| {
    value.method_which_requires_ownership();
    SomeType() // now give back a value of the same type
});

pub fn own_return<R, F>(&mut self, f: F) -> R where
    R: Sized,
    F: FnOnce(T) -> (T, R)
[src]

Takes temporary ownership of the contained value by passing it to f. The function must return a value of the same type (the same value, or a new value to take its place).

Like own, but uses a tuple return type which allows specifying a value to return from the call to own_return for convenience.

Example

let mut owner = Owner::new(123);
let doubled = owner.own_return(|n| (n, n * 2));

pub fn into_inner(self) -> T[src]

Sheds the Owner container and returns the value it contained.

Trait Implementations

impl<T> Deref for Owner<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> DerefMut for Owner<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Owner<T> where
    T: RefUnwindSafe

impl<T> Send for Owner<T> where
    T: Send

impl<T> Sync for Owner<T> where
    T: Sync

impl<T> Terminated for Owner<T> where
    T: Terminated

impl<T> Unpin for Owner<T> where
    T: Unpin

impl<T> UnwindSafe for Owner<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,