pub struct BoxBrand;Expand description
Brand for Box owned heap-allocated pointer.
BoxBrand implements Pointer and
ToDynFn but not
RefCountedPointer (since Box<dyn Fn> is not Clone).
Trait Implementations§
Source§impl Ord for BoxBrand
impl Ord for BoxBrand
Source§impl PartialOrd for BoxBrand
impl PartialOrd for BoxBrand
Source§impl Pointer for BoxBrand
impl Pointer for BoxBrand
Source§fn new<'a, T: 'a>(value: T) -> Box<T>
fn new<'a, T: 'a>(value: T) -> Box<T>
Wraps a sized value in a Box.
§Type Signature
forall T. T -> T
§Type Parameters
'a: The lifetime of the value.T: The type of the value to wrap.
§Parameters
value: The value to wrap.
§Returns
The value wrapped in a Box.
§Examples
use fp_library::{
brands::*,
classes::*,
};
let ptr = <BoxBrand as Pointer>::new(42);
assert_eq!(*ptr, 42);Source§impl ToDynFn for BoxBrand
impl ToDynFn for BoxBrand
Source§fn new<'a, A: 'a, B: 'a>(f: impl 'a + Fn(A) -> B) -> Box<dyn Fn(A) -> B + 'a>
fn new<'a, A: 'a, B: 'a>(f: impl 'a + Fn(A) -> B) -> Box<dyn Fn(A) -> B + 'a>
Coerces a sized closure to a dyn Fn wrapped in a Box.
§Type Signature
forall A B. (A -> B) -> A -> B
§Type Parameters
'a: The lifetime of the closure.A: The input type of the function.B: The output type of the function.
§Parameters
f: The closure to coerce.
§Returns
The closure wrapped in a Box as a trait object.
§Examples
use fp_library::{
brands::*,
classes::*,
};
let f = <BoxBrand as ToDynFn>::new(|x: i32| x + 1);
assert_eq!(f(1), 2);Source§fn ref_new<'a, A: 'a, B: 'a>(
f: impl 'a + Fn(&A) -> B,
) -> Box<dyn Fn(&A) -> B + 'a>
fn ref_new<'a, A: 'a, B: 'a>( f: impl 'a + Fn(&A) -> B, ) -> Box<dyn Fn(&A) -> B + 'a>
Coerces a sized by-reference closure to a dyn Fn(&A) -> B wrapped in a Box.
§Type Signature
forall A B. (&A -> B) -> &A -> B
§Type Parameters
'a: The lifetime of the closure.A: The input type (the closure receives&A).B: The output type of the function.
§Parameters
f: The closure to coerce.
§Returns
The closure wrapped in a Box as a by-reference trait object.
§Examples
use fp_library::{
brands::*,
classes::*,
};
let f = <BoxBrand as ToDynFn>::ref_new(|x: &i32| *x + 1);
assert_eq!(f(&1), 2);impl Copy for BoxBrand
impl Eq for BoxBrand
impl StructuralPartialEq for BoxBrand
Auto Trait Implementations§
impl Freeze for BoxBrand
impl RefUnwindSafe for BoxBrand
impl Send for BoxBrand
impl Sync for BoxBrand
impl Unpin for BoxBrand
impl UnsafeUnpin for BoxBrand
impl UnwindSafe for BoxBrand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more