pub trait ValueBoxPointer<T: Any> {
Show 21 methods // Required methods fn to_ref(&self) -> Result<BoxRef<T>>; fn take_value(&self) -> Result<T>; fn release(self); // Provided methods fn with_ref<R: Any, F>(&self, op: F) -> Result<R> where F: FnOnce(&T) -> Result<R> { ... } fn with_option_ref<R: Any, F>(&self, op: F) -> Result<R> where F: FnOnce(Option<&T>) -> Result<R> { ... } fn with_ref_ok<R: Any, F>(&self, op: F) -> Result<R> where F: FnOnce(&T) -> R { ... } fn with_mut<R: Any, F>(&self, op: F) -> Result<R> where F: FnOnce(&mut T) -> Result<R> { ... } fn with_mut_ok<R: Any, F>(&self, op: F) -> Result<R> where F: FnOnce(&mut T) -> R { ... } fn with_clone<R: Any, F>(&self, op: F) -> Result<R> where F: FnOnce(T) -> Result<R>, T: Clone { ... } fn with_clone_ok<R: Any, F>(&self, op: F) -> Result<R> where F: FnOnce(T) -> R, T: Clone { ... } fn with_ref_ref<R: Any, F, P: Any>( &self, ptr: *mut ValueBox<P>, op: F ) -> Result<R> where F: FnOnce(&T, &P) -> Result<R> { ... } fn with_ref_ref_ref<R: Any, F, P1: Any, P2: Any>( &self, ptr1: *mut ValueBox<P1>, ptr2: *mut ValueBox<P2>, op: F ) -> Result<R> where F: FnOnce(&T, &P1, &P2) -> Result<R> { ... } fn with_ref_ref_ref_ref<R: Any, F, P1: Any, P2: Any, P3: Any>( &self, ptr1: *mut ValueBox<P1>, ptr2: *mut ValueBox<P2>, ptr3: *mut ValueBox<P3>, op: F ) -> Result<R> where F: FnOnce(&T, &P1, &P2, &P3) -> Result<R> { ... } fn replace_value<F>(&self, op: F) -> Result<()> where F: FnOnce(T) -> T { ... } fn has_value(&self) -> bool { ... } fn is_valid(&self) -> bool { ... } fn with_not_null<Block>(&self, block: Block) where Block: FnOnce(&mut T) { ... } fn with_not_null_return<Block, Return: Any>( &self, default: Return, block: Block ) -> Return where Block: FnOnce(&mut T) -> Return { ... } fn with_value<DefaultBlock, Block, Return: Any>( &self, default: DefaultBlock, block: Block ) -> Return where DefaultBlock: FnOnce() -> Return, Block: FnOnce(T) -> Return, T: Clone { ... } fn with_not_null_value<Block>(&self, block: Block) where Block: FnOnce(T), T: Clone { ... } fn with_not_null_value_return<Block, Return: Any>( &self, default: Return, block: Block ) -> Return where Block: FnOnce(T) -> Return, T: Clone { ... }
}

Required Methods§

source

fn to_ref(&self) -> Result<BoxRef<T>>

Get the reference to the underlying box without dropping it.

source

fn take_value(&self) -> Result<T>

Take the value out of the box.

source

fn release(self)

Provided Methods§

source

fn with_ref<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(&T) -> Result<R>,

Evaluate a given function with a reference to the boxed value. The the reference can not outlive the closure.

source

fn with_option_ref<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(Option<&T>) -> Result<R>,

Try to unbox the value and evaluate a given function with either Some if the value was there or None if the pointer was a null pointer. Returns an error if the value box wasn’t a null pointer, but the boxed value was already taken or of the wrong type.

source

fn with_ref_ok<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(&T) -> R,

Evaluate a given function with a reference to the boxed value. The the reference can not outlive the closure.

source

fn with_mut<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(&mut T) -> Result<R>,

Evaluate a given function with a mutable reference to the boxed value. The lifetime of the reference can not outlive the closure.

source

fn with_mut_ok<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(&mut T) -> R,

Evaluate a given function that can not fail with a mutable reference to the boxed value. The lifetime of the reference can not outlive the closure.

source

fn with_clone<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(T) -> Result<R>, T: Clone,

Evaluate a given function with a clone of the boxed value. The boxed type T must implement Clone.

source

fn with_clone_ok<R: Any, F>(&self, op: F) -> Result<R>
where F: FnOnce(T) -> R, T: Clone,

Evaluate a given function with a clone of the boxed value. The boxed type T must implement Clone.

source

fn with_ref_ref<R: Any, F, P: Any>( &self, ptr: *mut ValueBox<P>, op: F ) -> Result<R>
where F: FnOnce(&T, &P) -> Result<R>,

Evaluate a given function with references to given boxed values. The lifetime of the reference can not outlive the closure.

source

fn with_ref_ref_ref<R: Any, F, P1: Any, P2: Any>( &self, ptr1: *mut ValueBox<P1>, ptr2: *mut ValueBox<P2>, op: F ) -> Result<R>
where F: FnOnce(&T, &P1, &P2) -> Result<R>,

Evaluate a given function with references to given boxed values. The lifetime of the reference can not outlive the closure.

source

fn with_ref_ref_ref_ref<R: Any, F, P1: Any, P2: Any, P3: Any>( &self, ptr1: *mut ValueBox<P1>, ptr2: *mut ValueBox<P2>, ptr3: *mut ValueBox<P3>, op: F ) -> Result<R>
where F: FnOnce(&T, &P1, &P2, &P3) -> Result<R>,

Evaluate a given function with references to given boxed values. The lifetime of the reference can not outlive the closure.

source

fn replace_value<F>(&self, op: F) -> Result<()>
where F: FnOnce(T) -> T,

Evaluate a given function with the value taken out of the box and place the new value back. The value returned by the function must be of the same type as the box

source

fn has_value(&self) -> bool

source

fn is_valid(&self) -> bool

👎Deprecated since 0.1.0: please use has_value instead
source

fn with_not_null<Block>(&self, block: Block)
where Block: FnOnce(&mut T),

👎Deprecated since 0.1.0: please use with_ref or with_mut instead
source

fn with_not_null_return<Block, Return: Any>( &self, default: Return, block: Block ) -> Return
where Block: FnOnce(&mut T) -> Return,

👎Deprecated since 0.1.0: please use with_ref or with_mut instead
source

fn with_value<DefaultBlock, Block, Return: Any>( &self, default: DefaultBlock, block: Block ) -> Return
where DefaultBlock: FnOnce() -> Return, Block: FnOnce(T) -> Return, T: Clone,

👎Deprecated since 0.1.0: please use with_ref or with_mut instead
source

fn with_not_null_value<Block>(&self, block: Block)
where Block: FnOnce(T), T: Clone,

👎Deprecated since 0.1.0: please use with_ref or with_mut instead
source

fn with_not_null_value_return<Block, Return: Any>( &self, default: Return, block: Block ) -> Return
where Block: FnOnce(T) -> Return, T: Clone,

👎Deprecated since 0.1.0: please use with_ref or with_mut instead

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: Any> ValueBoxPointer<T> for *mut ValueBox<T>

source§

fn to_ref(&self) -> Result<BoxRef<T>>

source§

fn take_value(&self) -> Result<T>

source§

fn release(self)

Implementors§