[−][src]Struct merk::owner::Owner
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]
R: Sized,
F: FnOnce(T) -> (T, R),
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
Auto Trait Implementations
impl<T> RefUnwindSafe for Owner<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Owner<T> where
T: Send,
T: Send,
impl<T> Sync for Owner<T> where
T: Sync,
T: Sync,
impl<T> Terminated for Owner<T> where
T: Terminated,
T: Terminated,
impl<T> Unpin for Owner<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Owner<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,