pub struct ConstBrand<R>(/* private fields */);Expand description
Brand for the Const functor.
Trait Implementations§
Source§impl<R: 'static + Semigroup> ApplyFirst for ConstBrand<R>
§Type Parameters
R: The stored type.
impl<R: 'static + Semigroup> ApplyFirst for ConstBrand<R>
§Type Parameters
R: The stored type.
Source§fn apply_first<'a, A: 'a, B: 'a>(
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn apply_first<'a, A: 'a, B: 'a>( fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
§Type Signature
forall R A B. Semigroup R => (Const R A, Const R B) -> Const R A
§Type Parameters
'a: The lifetime of the values.A: The first type.B: The second type.
§Parameters
fa: The firstConstinstance.fb: The secondConstinstance.
§Returns
A new Const instance with the combined stored values.
§Examples
use fp_library::{
brands::ConstBrand,
classes::apply_first::ApplyFirst,
types::const_val::Const,
};
let c1: Const<String, i32> = Const::new("Hello".to_string());
let c2: Const<String, i32> = Const::new(" World".to_string());
let applied = ConstBrand::apply_first(c1, c2);
assert_eq!(applied.0, "Hello World");Source§impl<R: 'static + Semigroup> ApplySecond for ConstBrand<R>
§Type Parameters
R: The stored type.
impl<R: 'static + Semigroup> ApplySecond for ConstBrand<R>
§Type Parameters
R: The stored type.
Source§fn apply_second<'a, A: 'a, B: 'a>(
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn apply_second<'a, A: 'a, B: 'a>( fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall R A B. Semigroup R => (Const R A, Const R B) -> Const R B
§Type Parameters
'a: The lifetime of the values.A: The first type.B: The second type.
§Parameters
fa: The firstConstinstance.fb: The secondConstinstance.
§Returns
A new Const instance with the combined stored values.
§Examples
use fp_library::{
brands::ConstBrand,
classes::apply_second::ApplySecond,
types::const_val::Const,
};
let c1: Const<String, i32> = Const::new("Hello".to_string());
let c2: Const<String, i32> = Const::new(" World".to_string());
let applied = ConstBrand::apply_second(c1, c2);
assert_eq!(applied.0, "Hello World");Source§impl<R: Clone> Clone for ConstBrand<R>
impl<R: Clone> Clone for ConstBrand<R>
Source§fn clone(&self) -> ConstBrand<R>
fn clone(&self) -> ConstBrand<R>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<R: Debug> Debug for ConstBrand<R>
impl<R: Debug> Debug for ConstBrand<R>
Source§impl<R: Default> Default for ConstBrand<R>
impl<R: Default> Default for ConstBrand<R>
Source§fn default() -> ConstBrand<R>
fn default() -> ConstBrand<R>
Source§impl<R: 'static> Functor for ConstBrand<R>
§Type Parameters
R: The stored type.
impl<R: 'static> Functor for ConstBrand<R>
§Type Parameters
R: The stored type.
Source§fn map<'a, A: 'a, B: 'a>(
_f: impl Fn(A) -> B + 'a,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn map<'a, A: 'a, B: 'a>( _f: impl Fn(A) -> B + 'a, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall R A B. (A -> B, Const R A) -> Const R B
§Type Parameters
'a: The lifetime of the values.A: The input type.B: The output type.
§Parameters
_f: The function to map (ignored).fa: TheConstinstance to map over.
§Returns
A new Const instance with the same stored value.
§Examples
use fp_library::{
brands::ConstBrand,
classes::functor::Functor,
types::const_val::Const,
};
let c: Const<i32, String> = Const::new(42);
let mapped = ConstBrand::map(|s: String| s.len(), c);
assert_eq!(mapped.0, 42);Source§impl<R: Hash> Hash for ConstBrand<R>
impl<R: Hash> Hash for ConstBrand<R>
Source§impl<'a, A: 'a, R: 'static> InferableBrand_cdc7cd43dac7585f<'a, ConstBrand<R>, A> for Const<'a, R, A>
Generated InferableBrand_cdc7cd43dac7585f implementation for Const < 'a, R, A > with brand ConstBrand < R >.
impl<'a, A: 'a, R: 'static> InferableBrand_cdc7cd43dac7585f<'a, ConstBrand<R>, A> for Const<'a, R, A>
Generated InferableBrand_cdc7cd43dac7585f implementation for Const < 'a, R, A > with brand ConstBrand < R >.
Source§impl<R: 'static> Kind_cdc7cd43dac7585f for ConstBrand<R>
Generated implementation of Kind_cdc7cd43dac7585f for ConstBrand < R >.
impl<R: 'static> Kind_cdc7cd43dac7585f for ConstBrand<R>
Generated implementation of Kind_cdc7cd43dac7585f for ConstBrand < R >.
Source§impl<R: 'static + Semigroup> Lift for ConstBrand<R>
§Type Parameters
R: The stored type.
impl<R: 'static + Semigroup> Lift for ConstBrand<R>
§Type Parameters
R: The stored type.
Source§fn lift2<'a, A, B, C>(
_func: impl Fn(A, B) -> C + 'a,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, C>
fn lift2<'a, A, B, C>( _func: impl Fn(A, B) -> C + 'a, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, C>
§Type Signature
forall R A B C. Semigroup R => ((A, B) -> C, Const R A, Const R B) -> Const R C
§Type Parameters
'a: The lifetime of the values.A: The first input type.B: The second input type.C: The output type.
§Parameters
_func: The function to lift (ignored).fa: The firstConstinstance.fb: The secondConstinstance.
§Returns
A new Const instance with the combined stored values.
§Examples
use fp_library::{
brands::ConstBrand,
classes::lift::Lift,
types::const_val::Const,
};
let c1: Const<String, i32> = Const::new("Hello".to_string());
let c2: Const<String, i32> = Const::new(" World".to_string());
let lifted = ConstBrand::lift2(|a: i32, b: i32| a + b, c1, c2);
assert_eq!(lifted.0, "Hello World");Source§impl<R: Ord> Ord for ConstBrand<R>
impl<R: Ord> Ord for ConstBrand<R>
Source§fn cmp(&self, other: &ConstBrand<R>) -> Ordering
fn cmp(&self, other: &ConstBrand<R>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<R: PartialEq> PartialEq for ConstBrand<R>
impl<R: PartialEq> PartialEq for ConstBrand<R>
Source§impl<R: PartialOrd> PartialOrd for ConstBrand<R>
impl<R: PartialOrd> PartialOrd for ConstBrand<R>
Source§impl<R: 'static + Monoid> Pointed for ConstBrand<R>
§Type Parameters
R: The stored type.
impl<R: 'static + Monoid> Pointed for ConstBrand<R>
§Type Parameters
R: The stored type.
Source§fn pure<'a, A: 'a>(_a: A) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn pure<'a, A: 'a>(_a: A) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
§Type Signature
forall R A. Monoid R => A -> Const R A
§Type Parameters
'a: The lifetime of the values.A: The type to wrap (ignored).
§Parameters
_a: The value to wrap (ignored).
§Returns
A new Const instance with the empty value of the stored type.
§Examples
use fp_library::{
brands::ConstBrand,
classes::pointed::Pointed,
types::const_val::Const,
};
let c: Const<String, i32> = ConstBrand::pure(42);
assert_eq!(c.0, "".to_string());Source§impl<R: 'static + Semigroup> Semiapplicative for ConstBrand<R>
§Type Parameters
R: The stored type.
impl<R: 'static + Semigroup> Semiapplicative for ConstBrand<R>
§Type Parameters
R: The stored type.
Source§fn apply<'a, FnBrand: 'a + CloneFn, A: 'a + Clone, B: 'a>(
ff: <Self as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as CloneFn>::Of<'a, A, B>>,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn apply<'a, FnBrand: 'a + CloneFn, A: 'a + Clone, B: 'a>( ff: <Self as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as CloneFn>::Of<'a, A, B>>, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall R A B. (Semigroup R, CloneFn FnBrand) => (Const R (FnBrand A B), Const R A) -> Const R B
§Type Parameters
'a: The lifetime of the values.FnBrand: The function brand.A: The input type.B: The output type.
§Parameters
ff: TheConstinstance containing a function.fa: TheConstinstance containing a value.
§Returns
A new Const instance with the combined stored values.
§Examples
use fp_library::{
brands::{
ConstBrand,
RcFnBrand,
},
classes::{
clone_fn::CloneFn,
semiapplicative::Semiapplicative,
},
types::const_val::Const,
};
let c1 = Const::<String, _>::new("Hello".to_string());
let c2 = Const::<String, i32>::new(" World".to_string());
let applied = ConstBrand::<String>::apply::<RcFnBrand, i32, i32>(c1, c2);
assert_eq!(applied.0, "Hello World");impl<R: Copy> Copy for ConstBrand<R>
impl<R: Eq> Eq for ConstBrand<R>
impl<R> StructuralPartialEq for ConstBrand<R>
Auto Trait Implementations§
impl<R> Freeze for ConstBrand<R>
impl<R> RefUnwindSafe for ConstBrand<R>where
R: RefUnwindSafe,
impl<R> Send for ConstBrand<R>where
R: Send,
impl<R> Sync for ConstBrand<R>where
R: Sync,
impl<R> Unpin for ConstBrand<R>where
R: Unpin,
impl<R> UnsafeUnpin for ConstBrand<R>
impl<R> UnwindSafe for ConstBrand<R>where
R: UnwindSafe,
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
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>
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>
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