pub struct Tuple1Brand;Expand description
Brand for (A,), with A not filled in.
Trait Implementations§
Source§impl ApplyFirst for Tuple1Brand
impl ApplyFirst for Tuple1Brand
Source§fn apply_first<'a, A: 'a + Clone, B: 'a + Clone>(
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 + Clone, B: 'a + Clone>( fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>
Source§impl ApplySecond for Tuple1Brand
impl ApplySecond for Tuple1Brand
Source§fn apply_second<'a, A: 'a + Clone, B: 'a + Clone>(
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 + Clone, B: 'a + Clone>( fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
Source§impl Clone for Tuple1Brand
impl Clone for Tuple1Brand
Source§fn clone(&self) -> Tuple1Brand
fn clone(&self) -> Tuple1Brand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Tuple1Brand
impl Debug for Tuple1Brand
Source§impl Default for Tuple1Brand
impl Default for Tuple1Brand
Source§fn default() -> Tuple1Brand
fn default() -> Tuple1Brand
Source§impl Foldable for Tuple1Brand
impl Foldable for Tuple1Brand
Source§fn fold_right<'a, FnBrand, A: 'a, B: 'a, Func>(
func: Func,
initial: B,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> Bwhere
Func: Fn(A, B) -> B + 'a,
FnBrand: CloneableFn + 'a,
fn fold_right<'a, FnBrand, A: 'a, B: 'a, Func>(
func: Func,
initial: B,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> Bwhere
Func: Fn(A, B) -> B + 'a,
FnBrand: CloneableFn + 'a,
Folds the 1-tuple from the right.
This method performs a right-associative fold of the 1-tuple. Since it contains only one element, this is equivalent to applying the function to the element and the initial value.
§Type Signature
forall A B. ((A, B) -> B, B, Tuple1 A) -> B
§Type Parameters
'a: The lifetime of the values.FnBrand: The brand of the cloneable function to use.A: The type of the elements in the structure.B: The type of the accumulator.Func: The type of the folding function.
§Parameters
func: The function to apply to each element and the accumulator.initial: The initial value of the accumulator.fa: The tuple to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{brands::*, functions::*};
let x = (5,);
let y = fold_right::<RcFnBrand, Tuple1Brand, _, _, _>(|a, b| a + b, 10, x);
assert_eq!(y, 15);Source§fn fold_left<'a, FnBrand, A: 'a, B: 'a, Func>(
func: Func,
initial: B,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> Bwhere
Func: Fn(B, A) -> B + 'a,
FnBrand: CloneableFn + 'a,
fn fold_left<'a, FnBrand, A: 'a, B: 'a, Func>(
func: Func,
initial: B,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> Bwhere
Func: Fn(B, A) -> B + 'a,
FnBrand: CloneableFn + 'a,
Folds the 1-tuple from the left.
This method performs a left-associative fold of the 1-tuple. Since it contains only one element, this is equivalent to applying the function to the initial value and the element.
§Type Signature
forall A B. ((B, A) -> B, B, Tuple1 A) -> B
§Type Parameters
'a: The lifetime of the values.FnBrand: The brand of the cloneable function to use.A: The type of the elements in the structure.B: The type of the accumulator.Func: The type of the folding function.
§Parameters
func: The function to apply to the accumulator and each element.initial: The initial value of the accumulator.fa: The tuple to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{brands::*, functions::*};
let x = (5,);
let y = fold_left::<RcFnBrand, Tuple1Brand, _, _, _>(|b, a| b + a, 10, x);
assert_eq!(y, 15);Source§fn fold_map<'a, FnBrand, A: 'a, M, Func>(
func: Func,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> M
fn fold_map<'a, FnBrand, A: 'a, M, Func>( func: Func, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> M
Maps the value to a monoid and returns it.
This method maps the element of the 1-tuple to a monoid.
§Type Signature
forall A M. Monoid M => (A -> M, Tuple1 A) -> M
§Type Parameters
'a: The lifetime of the values.FnBrand: The brand of the cloneable function to use.A: The type of the elements in the structure.M: The type of the monoid.Func: The type of the mapping function.
§Parameters
func: The thread-safe function to map each element to a monoid.fa: The tuple to fold.
§Returns
The monoid value.
§Examples
use fp_library::{brands::*, functions::*};
let x = (5,);
let y = fold_map::<RcFnBrand, Tuple1Brand, _, _, _>(|a: i32| a.to_string(), x);
assert_eq!(y, "5".to_string());Source§impl Functor for Tuple1Brand
impl Functor for Tuple1Brand
Source§fn map<'a, A: 'a, B: 'a, Func>(
func: Func,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>where
Func: Fn(A) -> B + 'a,
fn map<'a, A: 'a, B: 'a, Func>(
func: Func,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>where
Func: Fn(A) -> B + 'a,
Maps a function over the value in the tuple.
This method applies a function to the value inside the 1-tuple, producing a new 1-tuple with the transformed value.
§Type Signature
forall A B. (A -> B, Tuple1 A) -> Tuple1 B
§Type Parameters
'a: The lifetime of the value.A: The type of the value inside the tuple.B: The type of the result of applying the function.Func: The type of the function to apply.
§Parameters
func: The function to apply.fa: The tuple to map over.
§Returns
A new 1-tuple containing the result of applying the function.
§Examples
use fp_library::{brands::*, functions::*};
let x = (5,);
let y = map::<Tuple1Brand, _, _, _>(|i| i * 2, x);
assert_eq!(y, (10,));Source§impl Hash for Tuple1Brand
impl Hash for Tuple1Brand
Source§impl Kind_ad6c20556a82a1f0 for Tuple1Brand
Generated implementation of Kind_ad6c20556a82a1f0 for Tuple1Brand.
impl Kind_ad6c20556a82a1f0 for Tuple1Brand
Generated implementation of Kind_ad6c20556a82a1f0 for Tuple1Brand.
Source§impl Kind_cdc7cd43dac7585f for Tuple1Brand
Generated implementation of Kind_cdc7cd43dac7585f for Tuple1Brand.
impl Kind_cdc7cd43dac7585f for Tuple1Brand
Generated implementation of Kind_cdc7cd43dac7585f for Tuple1Brand.
Source§impl Lift for Tuple1Brand
impl Lift for Tuple1Brand
Source§fn lift2<'a, A, B, C, Func>(
func: Func,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, C>where
Func: Fn(A, B) -> C + 'a,
A: 'a,
B: 'a,
C: 'a,
fn lift2<'a, A, B, C, Func>(
func: Func,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, C>where
Func: Fn(A, B) -> C + 'a,
A: 'a,
B: 'a,
C: 'a,
Lifts a binary function into the tuple context.
This method lifts a binary function to operate on values within the 1-tuple context.
§Type Signature
forall A B C. ((A, B) -> C, Tuple1 A, Tuple1 B) -> Tuple1 C
§Type Parameters
'a: The lifetime of the values.A: The type of the first tuple’s value.B: The type of the second tuple’s value.C: The return type of the function.Func: The type of the binary function.
§Parameters
func: The binary function to apply.fa: The first tuple.fb: The second tuple.
§Returns
A new 1-tuple containing the result of applying the function.
§Examples
use fp_library::{brands::*, functions::*};
let x = (1,);
let y = (2,);
let z = lift2::<Tuple1Brand, _, _, _, _>(|a, b| a + b, x, y);
assert_eq!(z, (3,));Source§impl Ord for Tuple1Brand
impl Ord for Tuple1Brand
Source§fn cmp(&self, other: &Tuple1Brand) -> Ordering
fn cmp(&self, other: &Tuple1Brand) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl ParFoldable for Tuple1Brand
impl ParFoldable for Tuple1Brand
Source§fn par_fold_map<'a, FnBrand, A, M>(
func: <FnBrand as SendCloneableFn>::SendOf<'a, A, M>,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> M
fn par_fold_map<'a, FnBrand, A, M>( func: <FnBrand as SendCloneableFn>::SendOf<'a, A, M>, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> M
Maps the value to a monoid and returns it in parallel.
This method maps the element of the 1-tuple to a monoid. Since it contains only one element, no actual parallelism occurs, but the interface is satisfied.
§Type Signature
forall A M. Monoid M => (A -> M, Tuple1 A) -> M
§Type Parameters
'a: The lifetime of the values.FnBrand: The brand of the cloneable function wrapper.A: The element type.M: The monoid type.
§Parameters
func: The function to map each element to a monoid.fa: The tuple to fold.
§Returns
The combined monoid value.
§Examples
use fp_library::{brands::*, functions::*};
let x = (1,);
let f = send_cloneable_fn_new::<ArcFnBrand, _, _>(|x: i32| x.to_string());
let y = par_fold_map::<ArcFnBrand, Tuple1Brand, _, _>(f, x);
assert_eq!(y, "1".to_string());Source§fn par_fold_right<'a, FnBrand, A, B>(
func: <FnBrand as SendCloneableFn>::SendOf<'a, (A, B), B>,
initial: B,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> B
fn par_fold_right<'a, FnBrand, A, B>( func: <FnBrand as SendCloneableFn>::SendOf<'a, (A, B), B>, initial: B, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
Folds the 1-tuple from the right in parallel.
This method performs a right-associative fold of the 1-tuple. Since it contains only one element, no actual parallelism occurs.
§Type Signature
forall A B. ((A, B) -> B, B, Tuple1 A) -> B
§Type Parameters
'a: The lifetime of the values.FnBrand: The brand of the cloneable function wrapper.A: The element type.B: The accumulator type.
§Parameters
func: The thread-safe function to apply to each element and the accumulator.initial: The initial value of the accumulator.fa: The tuple to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{brands::*, functions::*};
let x = (1,);
let f = send_cloneable_fn_new::<ArcFnBrand, _, _>(|(a, b): (i32, i32)| a + b);
let y = par_fold_right::<ArcFnBrand, Tuple1Brand, _, _>(f, 10, x);
assert_eq!(y, 11);Source§impl PartialEq for Tuple1Brand
impl PartialEq for Tuple1Brand
Source§impl PartialOrd for Tuple1Brand
impl PartialOrd for Tuple1Brand
Source§impl Pointed for Tuple1Brand
impl Pointed for Tuple1Brand
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>
Wraps a value in a 1-tuple.
This method wraps a value in a 1-tuple context.
§Type Signature
forall A. A -> Tuple1 A
§Type Parameters
'a: The lifetime of the value.A: The type of the value to wrap.
§Parameters
a: The value to wrap.
§Returns
A 1-tuple containing the value.
§Examples
use fp_library::{brands::*, functions::*};
let x = pure::<Tuple1Brand, _>(5);
assert_eq!(x, (5,));Source§impl Semiapplicative for Tuple1Brand
impl Semiapplicative for Tuple1Brand
Source§fn apply<'a, FnBrand: 'a + CloneableFn, A: 'a + Clone, B: 'a>(
ff: <Self as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as CloneableFn>::Of<'a, A, B>>,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn apply<'a, FnBrand: 'a + CloneableFn, A: 'a + Clone, B: 'a>( ff: <Self as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as CloneableFn>::Of<'a, A, B>>, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
Applies a wrapped function to a wrapped value.
This method applies a function wrapped in a 1-tuple to a value wrapped in a 1-tuple.
§Type Signature
forall A B. (Tuple1 (A -> B), Tuple1 A) -> Tuple1 B
§Type Parameters
'a: The lifetime of the values.FnBrand: The brand of the cloneable function wrapper.A: The type of the input value.B: The type of the output value.
§Parameters
ff: The tuple containing the function.fa: The tuple containing the value.
§Returns
A new 1-tuple containing the result of applying the function.
§Examples
use fp_library::{brands::*, functions::*};
let f = (cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2),);
let x = (5,);
let y = apply::<RcFnBrand, Tuple1Brand, _, _>(f, x);
assert_eq!(y, (10,));Source§impl Semimonad for Tuple1Brand
impl Semimonad for Tuple1Brand
Source§fn bind<'a, A: 'a, B: 'a, Func>(
ma: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
func: Func,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn bind<'a, A: 'a, B: 'a, Func>( ma: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, func: Func, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
Chains 1-tuple computations.
This method chains two 1-tuple computations, where the second computation depends on the result of the first.
§Type Signature
forall A B. (Tuple1 A, A -> Tuple1 B) -> Tuple1 B
§Type Parameters
'a: The lifetime of the values.A: The type of the result of the first computation.B: The type of the result of the second computation.Func: The type of the function to apply.
§Parameters
ma: The first tuple.func: The function to apply to the value inside the tuple.
§Returns
The result of applying f to the value.
§Examples
use fp_library::{brands::*, functions::*};
let x = (5,);
let y = bind::<Tuple1Brand, _, _, _>(x, |i| (i * 2,));
assert_eq!(y, (10,));Source§impl Traversable for Tuple1Brand
impl Traversable for Tuple1Brand
Source§fn traverse<'a, A: 'a + Clone, B: 'a + Clone, F: Applicative, Func>(
func: Func,
ta: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>>where
Func: Fn(A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
<Self as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
fn traverse<'a, A: 'a + Clone, B: 'a + Clone, F: Applicative, Func>(
func: Func,
ta: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>>where
Func: Fn(A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
<Self as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
Traverses the 1-tuple with an applicative function.
This method maps the element of the 1-tuple to a computation, evaluates it, and wraps the result in the applicative context.
§Type Signature
forall A B F. Applicative F => (A -> F B, Tuple1 A) -> F (Tuple1 B)
§Type Parameters
'a: The lifetime of the values.A: The type of the elements in the traversable structure.B: The type of the elements in the resulting traversable structure.F: The applicative context.Func: The type of the function to apply.
§Parameters
func: The function to apply to each element, returning a value in an applicative context.ta: The tuple to traverse.
§Returns
The 1-tuple wrapped in the applicative context.
§Examples
use fp_library::{brands::*, functions::*};
let x = (5,);
let y = traverse::<Tuple1Brand, _, _, OptionBrand, _>(|a| Some(a * 2), x);
assert_eq!(y, Some((10,)));Source§fn sequence<'a, A: 'a + Clone, F: Applicative>(
ta: <Self as Kind_cdc7cd43dac7585f>::Of<'a, <F as Kind_cdc7cd43dac7585f>::Of<'a, A>>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>>where
<F as Kind_cdc7cd43dac7585f>::Of<'a, A>: Clone,
<Self as Kind_cdc7cd43dac7585f>::Of<'a, A>: Clone,
fn sequence<'a, A: 'a + Clone, F: Applicative>(
ta: <Self as Kind_cdc7cd43dac7585f>::Of<'a, <F as Kind_cdc7cd43dac7585f>::Of<'a, A>>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>>where
<F as Kind_cdc7cd43dac7585f>::Of<'a, A>: Clone,
<Self as Kind_cdc7cd43dac7585f>::Of<'a, A>: Clone,
Sequences a 1-tuple of applicative.
This method evaluates the computation inside the 1-tuple and wraps the result in the applicative context.
§Type Signature
forall A F. Applicative F => Tuple1 (F A) -> F (Tuple1 A)
§Type Parameters
'a: The lifetime of the values.A: The type of the elements in the traversable structure.F: The applicative context.
§Parameters
ta: The tuple containing the applicative value.
§Returns
The 1-tuple wrapped in the applicative context.
§Examples
use fp_library::{brands::*, functions::*};
let x = (Some(5),);
let y = sequence::<Tuple1Brand, _, OptionBrand>(x);
assert_eq!(y, Some((5,)));impl Copy for Tuple1Brand
impl Eq for Tuple1Brand
impl StructuralPartialEq for Tuple1Brand
Auto Trait Implementations§
impl Freeze for Tuple1Brand
impl RefUnwindSafe for Tuple1Brand
impl Send for Tuple1Brand
impl Sync for Tuple1Brand
impl Unpin for Tuple1Brand
impl UnwindSafe for Tuple1Brand
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