pub struct RcBrand;Expand description
Brand for Rc reference-counted pointer.
Trait Implementations§
Source§impl Ord for RcBrand
impl Ord for RcBrand
Source§impl PartialOrd for RcBrand
impl PartialOrd for RcBrand
Source§impl Pointer for RcBrand
impl Pointer for RcBrand
Source§fn new<T>(value: T) -> Rc<T>
fn new<T>(value: T) -> Rc<T>
Wraps a sized value in an Rc.
§Type Signature
forall t. t -> t
§Type Parameters
T: The type of the value to wrap.
§Parameters
value: The value to wrap.
§Returns
The value wrapped in an Rc.
§Examples
use fp_library::{brands::*, functions::*};
let ptr = pointer_new::<RcBrand, _>(42);
assert_eq!(*ptr, 42);Source§impl RefCountedPointer for RcBrand
impl RefCountedPointer for RcBrand
Source§fn cloneable_new<T>(value: T) -> Rc<T>
fn cloneable_new<T>(value: T) -> Rc<T>
Wraps a sized value in an Rc.
§Type Signature
forall t. t -> t
§Type Parameters
T: The type of the value to wrap.
§Parameters
value: The value to wrap.
§Returns
The value wrapped in an Rc.
§Examples
use fp_library::{brands::*, functions::*};
let ptr = ref_counted_pointer_new::<RcBrand, _>(42);
assert_eq!(*ptr, 42);Source§fn try_unwrap<T>(ptr: Rc<T>) -> Result<T, Rc<T>>
fn try_unwrap<T>(ptr: Rc<T>) -> Result<T, Rc<T>>
Attempts to unwrap the inner value if this is the sole reference.
§Type Signature
forall t. t -> Result t t
§Type Parameters
T: The type of the wrapped value.
§Parameters
ptr: The pointer to attempt to unwrap.
§Returns
Ok(value) if this is the sole reference, otherwise Err(ptr).
§Examples
use fp_library::{brands::*, functions::*};
let ptr = ref_counted_pointer_new::<RcBrand, _>(42);
assert_eq!(try_unwrap::<RcBrand, _>(ptr), Ok(42));Source§impl UnsizedCoercible for RcBrand
impl UnsizedCoercible for RcBrand
Source§fn coerce_fn<'a, A, B>(f: impl 'a + Fn(A) -> B) -> Rc<dyn Fn(A) -> B + 'a>
fn coerce_fn<'a, A, B>(f: impl 'a + Fn(A) -> B) -> Rc<dyn Fn(A) -> B + 'a>
Coerces a sized closure to a dyn Fn wrapped in an Rc.
§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 an Rc as a trait object.
§Examples
use fp_library::{brands::*, functions::*};
let f = coerce_fn::<RcBrand, _, _, _>(|x: i32| x + 1);
assert_eq!(f(1), 2);impl Copy for RcBrand
impl Eq for RcBrand
impl StructuralPartialEq for RcBrand
Auto Trait Implementations§
impl Freeze for RcBrand
impl RefUnwindSafe for RcBrand
impl Send for RcBrand
impl Sync for RcBrand
impl Unpin for RcBrand
impl UnwindSafe for RcBrand
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