Trait value_box::ValueBoxPointer
source · pub trait ValueBoxPointer<T: Any> {
Show 21 methods
fn to_ref(&self) -> Result<BoxRef<T>>;
fn take_value(&self) -> Result<T>;
fn release(self);
fn with_ref<R: Any, F>(&self, op: F) -> Result<R>
where
F: FnOnce(&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 get_ptr(&self) -> *const T { ... }
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>where
F: FnOnce(&T) -> Result<R>,
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.
sourcefn with_ref_ok<R: Any, F>(&self, op: F) -> Result<R>where
F: FnOnce(&T) -> R,
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.
sourcefn with_mut<R: Any, F>(&self, op: F) -> Result<R>where
F: FnOnce(&mut T) -> Result<R>,
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.
sourcefn with_mut_ok<R: Any, F>(&self, op: F) -> Result<R>where
F: FnOnce(&mut T) -> R,
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.
sourcefn with_clone<R: Any, F>(&self, op: F) -> Result<R>where
F: FnOnce(T) -> Result<R>,
T: Clone,
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
.
sourcefn with_clone_ok<R: Any, F>(&self, op: F) -> Result<R>where
F: FnOnce(T) -> R,
T: Clone,
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
.
sourcefn 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<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.
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>where
F: FnOnce(&T, &P1, &P2) -> 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>,
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>where
F: FnOnce(&T, &P1, &P2, &P3) -> 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>,
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 get_ptr(&self) -> *const T
sourcefn with_not_null<Block>(&self, block: Block)where
Block: FnOnce(&mut T),
fn with_not_null<Block>(&self, block: Block)where
Block: FnOnce(&mut T),
with_ref
or with_mut
insteadsourcefn with_not_null_return<Block, Return: Any>(
&self,
default: Return,
block: Block
) -> Returnwhere
Block: FnOnce(&mut T) -> Return,
fn with_not_null_return<Block, Return: Any>(
&self,
default: Return,
block: Block
) -> Returnwhere
Block: FnOnce(&mut T) -> Return,
with_ref
or with_mut
insteadsourcefn with_value<DefaultBlock, Block, Return: Any>(
&self,
default: DefaultBlock,
block: Block
) -> Returnwhere
DefaultBlock: FnOnce() -> Return,
Block: FnOnce(T) -> Return,
T: Clone,
fn with_value<DefaultBlock, Block, Return: Any>(
&self,
default: DefaultBlock,
block: Block
) -> Returnwhere
DefaultBlock: FnOnce() -> Return,
Block: FnOnce(T) -> Return,
T: Clone,
with_ref
or with_mut
insteadsourcefn with_not_null_value<Block>(&self, block: Block)where
Block: FnOnce(T),
T: Clone,
fn with_not_null_value<Block>(&self, block: Block)where
Block: FnOnce(T),
T: Clone,
with_ref
or with_mut
insteadsourcefn with_not_null_value_return<Block, Return: Any>(
&self,
default: Return,
block: Block
) -> Returnwhere
Block: FnOnce(T) -> Return,
T: Clone,
fn with_not_null_value_return<Block, Return: Any>(
&self,
default: Return,
block: Block
) -> Returnwhere
Block: FnOnce(T) -> Return,
T: Clone,
with_ref
or with_mut
instead