pub struct ControlFlowBreakAppliedBrand<B>(/* private fields */);Expand description
Brand for the partially-applied form of ControlFlow with the Break type applied.
Fixes the Break (result) type, yielding a Functor over the Continue
(continuation) type.
Trait Implementations§
Source§impl<BreakType: Clone + 'static> ApplyFirst for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
impl<BreakType: Clone + 'static> ApplyFirst for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
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<BreakType: Clone + 'static> ApplySecond for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
impl<BreakType: Clone + 'static> ApplySecond for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
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<B: Clone> Clone for ControlFlowBreakAppliedBrand<B>
impl<B: Clone> Clone for ControlFlowBreakAppliedBrand<B>
Source§fn clone(&self) -> ControlFlowBreakAppliedBrand<B>
fn clone(&self) -> ControlFlowBreakAppliedBrand<B>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<B: Debug> Debug for ControlFlowBreakAppliedBrand<B>
impl<B: Debug> Debug for ControlFlowBreakAppliedBrand<B>
Source§impl<B: Default> Default for ControlFlowBreakAppliedBrand<B>
impl<B: Default> Default for ControlFlowBreakAppliedBrand<B>
Source§fn default() -> ControlFlowBreakAppliedBrand<B>
fn default() -> ControlFlowBreakAppliedBrand<B>
Source§impl<BreakType: 'static> Foldable for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
impl<BreakType: 'static> Foldable for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
Source§fn fold_right<'a, FnBrand, A: 'a, B: 'a>(
func: impl Fn(A, B) -> B + 'a,
initial: B,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> Bwhere
FnBrand: CloneFn + 'a,
fn fold_right<'a, FnBrand, A: 'a, B: 'a>(
func: impl Fn(A, B) -> B + 'a,
initial: B,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> Bwhere
FnBrand: CloneFn + 'a,
Folds the control flow from the right (over continue).
This method performs a right-associative fold of the control flow (over continue).
§Type Signature
forall BreakType A B. CloneFn FnBrand => ((A, B) -> B, B, ControlFlowBreakApplied BreakType 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.
§Parameters
func: The folding function.initial: The initial value.fa: The control flow to fold.
§Returns
func(a, initial) if fa is Continue(a), otherwise initial.
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
assert_eq!(
explicit::fold_right::<RcFnBrand, ControlFlowBreakAppliedBrand<i32>, _, _, _, _>(
|x: i32, acc| x + acc,
0,
ControlFlow::Continue(1)
),
1
);
assert_eq!(
explicit::fold_right::<RcFnBrand, ControlFlowBreakAppliedBrand<()>, _, _, _, _>(
|x: i32, acc| x + acc,
0,
ControlFlow::Break(())
),
0
);Source§fn fold_left<'a, FnBrand, A: 'a, B: 'a>(
func: impl Fn(B, A) -> B + 'a,
initial: B,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> Bwhere
FnBrand: CloneFn + 'a,
fn fold_left<'a, FnBrand, A: 'a, B: 'a>(
func: impl Fn(B, A) -> B + 'a,
initial: B,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> Bwhere
FnBrand: CloneFn + 'a,
Folds the control flow from the left (over continue).
This method performs a left-associative fold of the control flow (over continue).
§Type Signature
forall BreakType A B. CloneFn FnBrand => ((B, A) -> B, B, ControlFlowBreakApplied BreakType 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.
§Parameters
func: The folding function.initial: The initial value.fa: The control flow to fold.
§Returns
func(initial, a) if fa is Continue(a), otherwise initial.
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
assert_eq!(
explicit::fold_left::<RcFnBrand, ControlFlowBreakAppliedBrand<()>, _, _, _, _>(
|acc, x: i32| acc + x,
0,
ControlFlow::Continue(5)
),
5
);
assert_eq!(
explicit::fold_left::<RcFnBrand, ControlFlowBreakAppliedBrand<i32>, _, _, _, _>(
|acc, x: i32| acc + x,
0,
ControlFlow::Break(1)
),
0
);Source§fn fold_map<'a, FnBrand, A: 'a, M>(
func: impl Fn(A) -> M + 'a,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> M
fn fold_map<'a, FnBrand, A: 'a, M>( func: impl Fn(A) -> M + 'a, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> M
Maps the value to a monoid and returns it (over continue).
This method maps the element of the control flow to a monoid and then returns it (over continue).
§Type Signature
forall BreakType A M. (Monoid M, CloneFn FnBrand) => (A -> M, ControlFlowBreakApplied BreakType 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.
§Parameters
func: The mapping function.fa: The control flow to fold.
§Returns
func(a) if fa is Continue(a), otherwise M::empty().
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
assert_eq!(
explicit::fold_map::<RcFnBrand, ControlFlowBreakAppliedBrand<()>, _, _, _, _>(
|x: i32| x.to_string(),
ControlFlow::Continue(5)
),
"5".to_string()
);
assert_eq!(
explicit::fold_map::<RcFnBrand, ControlFlowBreakAppliedBrand<i32>, _, _, _, _>(
|x: i32| x.to_string(),
ControlFlow::Break(1)
),
"".to_string()
);Source§impl<BreakType: 'static> Functor for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
impl<BreakType: 'static> Functor for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
Source§fn map<'a, A: 'a, B: 'a>(
func: 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>( func: impl Fn(A) -> B + 'a, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
Maps a function over the continue value in the control flow.
This method applies a function to the continue value inside the control flow, producing a new control flow with the transformed continue value. The break value remains unchanged.
§Type Signature
forall BreakType A B. (A -> B, ControlFlowBreakApplied BreakType A) -> ControlFlowBreakApplied BreakType B
§Type Parameters
'a: The lifetime of the values.A: The type of the continue value.B: The type of the result of applying the function.
§Parameters
func: The function to apply to the continue value.fa: The control flow to map over.
§Returns
A new control flow containing the result of applying the function to the continue value.
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
assert_eq!(
explicit::map::<ControlFlowBreakAppliedBrand<i32>, _, _, _, _>(
|x: i32| x * 2,
ControlFlow::<i32, i32>::Continue(5)
),
ControlFlow::Continue(10)
);Source§impl<B: Hash> Hash for ControlFlowBreakAppliedBrand<B>
impl<B: Hash> Hash for ControlFlowBreakAppliedBrand<B>
Source§impl<BreakType: 'static> Kind_cdc7cd43dac7585f for ControlFlowBreakAppliedBrand<BreakType>
Generated implementation of Kind_cdc7cd43dac7585f for ControlFlowBreakAppliedBrand < BreakType >.
impl<BreakType: 'static> Kind_cdc7cd43dac7585f for ControlFlowBreakAppliedBrand<BreakType>
Generated implementation of Kind_cdc7cd43dac7585f for ControlFlowBreakAppliedBrand < BreakType >.
Source§type Of<'a, C: 'a> = ControlFlow<BreakType, C>
type Of<'a, C: 'a> = ControlFlow<BreakType, C>
Source§impl<BreakType: Clone + 'static> Lift for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
impl<BreakType: Clone + 'static> Lift for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break 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>
Lifts a binary function into the control flow context (over continue).
This method lifts a binary function to operate on continue values within the control flow context.
§Type Signature
forall BreakType A B C. ((A, B) -> C, ControlFlowBreakApplied BreakType A, ControlFlowBreakApplied BreakType B) -> ControlFlowBreakApplied BreakType C
§Type Parameters
'a: The lifetime of the values.A: The type of the first continue value.B: The type of the second continue value.C: The type of the result continue value.
§Parameters
func: The binary function to apply to the continues.fa: The first control flow.fb: The second control flow.
§Returns
Continue(f(a, b)) if both are Continue, otherwise the first break encountered.
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
assert_eq!(
explicit::lift2::<ControlFlowBreakAppliedBrand<i32>, _, _, _, _, _, _>(
|x: i32, y: i32| x + y,
ControlFlow::Continue(1),
ControlFlow::Continue(2)
),
ControlFlow::Continue(3)
);
assert_eq!(
explicit::lift2::<ControlFlowBreakAppliedBrand<i32>, _, _, _, _, _, _>(
|x: i32, y: i32| x + y,
ControlFlow::Continue(1),
ControlFlow::Break(2)
),
ControlFlow::Break(2)
);Source§impl<BreakType: Clone + 'static> MonadRec for ControlFlowBreakAppliedBrand<BreakType>
MonadRec implementation for ControlFlowBreakAppliedBrand.
impl<BreakType: Clone + 'static> MonadRec for ControlFlowBreakAppliedBrand<BreakType>
MonadRec implementation for ControlFlowBreakAppliedBrand.
§Type Parameters
BreakType: The break type.
Source§fn tail_rec_m<'a, A: 'a, B: 'a>(
func: impl Fn(A) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, ControlFlow<B, A>> + 'a,
initial: A,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn tail_rec_m<'a, A: 'a, B: 'a>( func: impl Fn(A) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, ControlFlow<B, A>> + 'a, initial: A, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
Performs tail-recursive monadic computation over ControlFlow (continue channel).
Iteratively applies the step function. If the function returns ControlFlow::Break,
the computation short-circuits with that break value. If it returns
Continue(ControlFlow::Continue(a)), the loop continues with the new state. If it returns
Continue(ControlFlow::Break(b)), the computation completes with Continue(b).
§Type Signature
forall BreakType A B. (A -> ControlFlowBreakApplied BreakType (ControlFlow B A), A) -> ControlFlowBreakApplied BreakType B
§Type Parameters
'a: The lifetime of the computation.A: The type of the initial value and loop state.B: The type of the result.
§Parameters
func: The step function.initial: The initial value.
§Returns
The result of the computation, or a break if the step function returned Break.
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
let result = tail_rec_m::<ControlFlowBreakAppliedBrand<&str>, _, _>(
|n| {
if n < 10 {
ControlFlow::Continue(ControlFlow::Continue(n + 1))
} else {
ControlFlow::Continue(ControlFlow::Break(n))
}
},
0,
);
assert_eq!(result, ControlFlow::Continue(10));Source§impl<B: Ord> Ord for ControlFlowBreakAppliedBrand<B>
impl<B: Ord> Ord for ControlFlowBreakAppliedBrand<B>
Source§fn cmp(&self, other: &ControlFlowBreakAppliedBrand<B>) -> Ordering
fn cmp(&self, other: &ControlFlowBreakAppliedBrand<B>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<B: PartialEq> PartialEq for ControlFlowBreakAppliedBrand<B>
impl<B: PartialEq> PartialEq for ControlFlowBreakAppliedBrand<B>
Source§fn eq(&self, other: &ControlFlowBreakAppliedBrand<B>) -> bool
fn eq(&self, other: &ControlFlowBreakAppliedBrand<B>) -> bool
self and other values to be equal, and is used by ==.Source§impl<B: PartialOrd> PartialOrd for ControlFlowBreakAppliedBrand<B>
impl<B: PartialOrd> PartialOrd for ControlFlowBreakAppliedBrand<B>
Source§impl<BreakType: 'static> Pointed for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
impl<BreakType: 'static> Pointed for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break 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>
Wraps a value in a control flow (as continue).
This method wraps a value in the Continue variant of a ControlFlow.
§Type Signature
forall BreakType A. A -> ControlFlowBreakApplied BreakType A
§Type Parameters
'a: The lifetime of the value.A: The type of the value to wrap.
§Parameters
a: The value to wrap.
§Returns
Continue(a).
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
assert_eq!(pure::<ControlFlowBreakAppliedBrand<()>, _>(5), ControlFlow::<(), _>::Continue(5));Source§impl<BreakType: Clone + 'static> Semiapplicative for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
impl<BreakType: Clone + 'static> Semiapplicative for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break 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>
Applies a wrapped function to a wrapped value (over continue).
This method applies a function wrapped in a control flow (as continue) to a value wrapped in a control flow (as continue).
§Type Signature
forall BreakType A B. CloneFn FnBrand => (ControlFlowBreakApplied BreakType (FnBrand A B), ControlFlowBreakApplied BreakType A) -> ControlFlowBreakApplied BreakType 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 control flow containing the function (in Continue).fa: The control flow containing the value (in Continue).
§Returns
Continue(f(a)) if both are Continue, otherwise the first break encountered.
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
classes::*,
functions::*,
},
};
let f: ControlFlow<(), _> =
ControlFlow::Continue(lift_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2));
assert_eq!(
apply::<RcFnBrand, ControlFlowBreakAppliedBrand<()>, _, _>(f, ControlFlow::Continue(5)),
ControlFlow::Continue(10)
);Source§impl<BreakType: Clone + 'static> Semimonad for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
impl<BreakType: Clone + 'static> Semimonad for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
Source§fn bind<'a, A: 'a, B: 'a>(
ma: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
func: impl Fn(A) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn bind<'a, A: 'a, B: 'a>( ma: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, func: impl Fn(A) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>
Chains control flow computations (over continue).
This method chains two computations, where the second computation depends on the result of the first (over continue).
§Type Signature
forall BreakType A B. (ControlFlowBreakApplied BreakType A, A -> ControlFlowBreakApplied BreakType B) -> ControlFlowBreakApplied BreakType 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.
§Parameters
ma: The first control flow.func: The function to apply to the continue value.
§Returns
The result of applying f to the continue if ma is Continue, otherwise the original break.
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
assert_eq!(
explicit::bind::<ControlFlowBreakAppliedBrand<()>, _, _, _, _>(
ControlFlow::Continue(5),
|x| { ControlFlow::Continue(x * 2) }
),
ControlFlow::<(), _>::Continue(10)
);Source§impl<BreakType: Clone + 'static> Traversable for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
impl<BreakType: Clone + 'static> Traversable for ControlFlowBreakAppliedBrand<BreakType>
§Type Parameters
BreakType: The break type.
Source§fn traverse<'a, A: 'a + Clone, B: 'a + Clone, F: Applicative>(
func: impl Fn(A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
ta: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>>
fn traverse<'a, A: 'a + Clone, B: 'a + Clone, F: Applicative>( func: impl Fn(A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a, ta: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Self as Kind_cdc7cd43dac7585f>::Of<'a, B>>
Traverses the control flow with an applicative function (over continue).
This method maps the element of the control flow to a computation, evaluates it, and combines the result into an applicative context (over continue).
§Type Signature
forall BreakType A B F. Applicative F => (A -> F B, ControlFlowBreakApplied BreakType A) -> F (ControlFlowBreakApplied BreakType 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.
§Parameters
func: The function to apply.ta: The control flow to traverse.
§Returns
The control flow wrapped in the applicative context.
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
assert_eq!(
explicit::traverse::<RcFnBrand, ControlFlowBreakAppliedBrand<()>, _, _, OptionBrand, _, _>(
|x| Some(x * 2),
ControlFlow::Continue(5)
),
Some(ControlFlow::Continue(10))
);
assert_eq!(
explicit::traverse::<RcFnBrand, ControlFlowBreakAppliedBrand<i32>, _, _, OptionBrand, _, _>(
|x: i32| Some(x * 2),
ControlFlow::Break(1)
),
Some(ControlFlow::Break(1))
);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 control flow of applicative (over continue).
This method evaluates the computation inside the control flow and accumulates the result into an applicative context (over continue).
§Type Signature
forall BreakType A F. Applicative F => ControlFlowBreakApplied BreakType (F A) -> F (ControlFlowBreakApplied BreakType 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 control flow containing the applicative value.
§Returns
The control flow wrapped in the applicative context.
§Examples
use {
core::ops::ControlFlow,
fp_library::{
brands::*,
functions::*,
},
};
assert_eq!(
sequence::<ControlFlowBreakAppliedBrand<()>, _, OptionBrand>(ControlFlow::Continue(Some(
5
))),
Some(ControlFlow::Continue(5))
);
assert_eq!(
sequence::<ControlFlowBreakAppliedBrand<i32>, i32, OptionBrand>(ControlFlow::<
i32,
Option<i32>,
>::Break(1)),
Some(ControlFlow::<i32, i32>::Break(1))
);impl<B: Copy> Copy for ControlFlowBreakAppliedBrand<B>
impl<B: Eq> Eq for ControlFlowBreakAppliedBrand<B>
impl<B> StructuralPartialEq for ControlFlowBreakAppliedBrand<B>
Auto Trait Implementations§
impl<B> Freeze for ControlFlowBreakAppliedBrand<B>
impl<B> RefUnwindSafe for ControlFlowBreakAppliedBrand<B>where
B: RefUnwindSafe,
impl<B> Send for ControlFlowBreakAppliedBrand<B>where
B: Send,
impl<B> Sync for ControlFlowBreakAppliedBrand<B>where
B: Sync,
impl<B> Unpin for ControlFlowBreakAppliedBrand<B>where
B: Unpin,
impl<B> UnsafeUnpin for ControlFlowBreakAppliedBrand<B>
impl<B> UnwindSafe for ControlFlowBreakAppliedBrand<B>where
B: 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