Trait value_box::ValueBoxPointer
source · 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§
sourcefn to_ref(&self) -> Result<BoxRef<T>>
fn to_ref(&self) -> Result<BoxRef<T>>
Get the reference to the underlying box without dropping it.
sourcefn take_value(&self) -> Result<T>
fn take_value(&self) -> Result<T>
Take the value out of the box.
fn release(self)
Provided Methods§
sourcefn with_ref<R: Any, F>(&self, op: F) -> Result<R>
fn with_ref<R: Any, F>(&self, op: F) -> Result<R>
Evaluate a given function with a reference to the boxed value. The the reference can not outlive the closure.
sourcefn with_option_ref<R: Any, F>(&self, op: F) -> Result<R>
fn with_option_ref<R: Any, F>(&self, op: F) -> 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.
sourcefn with_ref_ok<R: Any, F>(&self, op: F) -> Result<R>
fn with_ref_ok<R: Any, F>(&self, op: F) -> Result<R>
Evaluate a given function with a reference to the boxed value. The the reference can not outlive the closure.
sourcefn with_mut<R: Any, F>(&self, op: F) -> Result<R>
fn with_mut<R: Any, F>(&self, op: F) -> Result<R>
Evaluate a given function with a mutable reference to the boxed value. The lifetime of the reference can not outlive the closure.
sourcefn with_mut_ok<R: Any, F>(&self, op: F) -> Result<R>
fn with_mut_ok<R: Any, F>(&self, op: F) -> Result<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.
sourcefn with_clone<R: Any, F>(&self, op: F) -> Result<R>
fn with_clone<R: Any, F>(&self, op: F) -> Result<R>
Evaluate a given function with a clone of the boxed value.
The boxed type T
must implement Clone
.
sourcefn with_clone_ok<R: Any, F>(&self, op: F) -> Result<R>
fn with_clone_ok<R: Any, F>(&self, op: F) -> Result<R>
Evaluate a given function with a clone of the boxed value.
The boxed type T
must implement Clone
.
sourcefn with_ref_ref<R: Any, F, P: Any>(
&self,
ptr: *mut ValueBox<P>,
op: F
) -> Result<R>
fn with_ref_ref<R: Any, F, P: Any>( &self, ptr: *mut ValueBox<P>, op: F ) -> Result<R>
Evaluate a given function with references to given boxed values. The lifetime of the reference can not outlive the closure.
sourcefn with_ref_ref_ref<R: Any, F, P1: Any, P2: Any>(
&self,
ptr1: *mut ValueBox<P1>,
ptr2: *mut ValueBox<P2>,
op: F
) -> 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>
Evaluate a given function with references to given boxed values. The lifetime of the reference can not outlive the closure.
sourcefn 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>
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>
Evaluate a given function with references to given boxed values. The lifetime of the reference can not outlive the closure.
sourcefn replace_value<F>(&self, op: F) -> Result<()>where
F: FnOnce(T) -> T,
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
fn has_value(&self) -> bool
fn is_valid(&self) -> bool
has_value
insteadfn with_not_null<Block>(&self, block: Block)
with_ref
or with_mut
insteadfn with_not_null_return<Block, Return: Any>( &self, default: Return, block: Block ) -> Return
with_ref
or with_mut
insteadfn with_value<DefaultBlock, Block, Return: Any>( &self, default: DefaultBlock, block: Block ) -> Return
with_ref
or with_mut
insteadfn with_not_null_value<Block>(&self, block: Block)
with_ref
or with_mut
insteadfn with_not_null_value_return<Block, Return: Any>( &self, default: Return, block: Block ) -> Return
with_ref
or with_mut
instead