pub struct ShortCircuit<S, E> { /* private fields */ }Expand description
Short-circuits on the first Err in a yielded Result.
Converts Sans<I, Result<O, E>, Return = P> to Sans<I, O, Return = Result<P, E>>.
If any yield is Err(e), immediately completes with Err(e).
Otherwise yields unwrapped Ok values and completes with Ok(P).
Trait Implementations§
Source§impl<I, O, E, S> InitSans<I, O> for ShortCircuit<S, E>
impl<I, O, E, S> InitSans<I, O> for ShortCircuit<S, E>
type Next = ShortCircuit<<S as InitSans<I, Result<O, E>>>::Next, E>
Source§fn init(
self,
) -> Step<(O, Self::Next), Result<<S::Next as Sans<I, Result<O, E>>>::Return, E>>
fn init( self, ) -> Step<(O, Self::Next), Result<<S::Next as Sans<I, Result<O, E>>>::Return, E>>
Execute the first coroutine. Read more
Source§fn chain_once<F>(self, f: F) -> Chain<Self, Once<F>>
fn chain_once<F>(self, f: F) -> Chain<Self, Once<F>>
Chain with a function that executes once.
Source§fn chain_repeat<F>(self, f: F) -> Chain<Self, Repeat<F>>
fn chain_repeat<F>(self, f: F) -> Chain<Self, Repeat<F>>
Chain with a function that repeats indefinitely.
Source§fn map_input<I2, F>(self, f: F) -> MapInput<Self, F>
fn map_input<I2, F>(self, f: F) -> MapInput<Self, F>
Transform inputs before they reach the underlying coroutine.
Source§fn map_yield<O2, F>(self, f: F) -> MapYield<Self, F, I, O>
fn map_yield<O2, F>(self, f: F) -> MapYield<Self, F, I, O>
Transform yielded values before returning them.
Source§impl<I, O, E, S> Sans<I, O> for ShortCircuit<S, E>
impl<I, O, E, S> Sans<I, O> for ShortCircuit<S, E>
Source§type Return = Result<<S as Sans<I, Result<O, E>>>::Return, E>
type Return = Result<<S as Sans<I, Result<O, E>>>::Return, E>
Type of final result when computation completes
Source§fn next(&mut self, input: I) -> Step<O, Self::Return>
fn next(&mut self, input: I) -> Step<O, Self::Return>
Process input, returning
Yield to continue or Return to complete.Source§fn and_then<T, F>(self, f: F) -> AndThen<Self, T::Next, F>
fn and_then<T, F>(self, f: F) -> AndThen<Self, T::Next, F>
Chain with a coroutine created from this coroutine’s return value. Read more
fn boxed(self) -> Box<dyn Sans<I, O, Return = Self::Return>>where
Self: Sized + 'static,
Source§fn chain_once<F>(self, f: F) -> Chain<Self, Once<F>>
fn chain_once<F>(self, f: F) -> Chain<Self, Once<F>>
Chain with a function that executes once.
Source§fn chain_repeat<F>(self, f: F) -> Chain<Self, Repeat<F>>
fn chain_repeat<F>(self, f: F) -> Chain<Self, Repeat<F>>
Chain with a function that repeats indefinitely.
Source§fn map_input<I2, F>(self, f: F) -> MapInput<Self, F>
fn map_input<I2, F>(self, f: F) -> MapInput<Self, F>
Transform inputs before they reach this coroutine.
Source§fn map_yield<O2, F>(self, f: F) -> MapYield<Self, F, I, O>
fn map_yield<O2, F>(self, f: F) -> MapYield<Self, F, I, O>
Transform yielded values before returning them.
Source§fn map_return<D2, F>(self, f: F) -> MapReturn<Self, F>
fn map_return<D2, F>(self, f: F) -> MapReturn<Self, F>
Transform the final result when completing.
Auto Trait Implementations§
impl<S, E> Freeze for ShortCircuit<S, E>
impl<S, E> RefUnwindSafe for ShortCircuit<S, E>
impl<S, E> Send for ShortCircuit<S, E>
impl<S, E> Sync for ShortCircuit<S, E>
impl<S, E> Unpin for ShortCircuit<S, E>
impl<S, E> UnsafeUnpin for ShortCircuit<S, E>
impl<S, E> UnwindSafe for ShortCircuit<S, E>
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> 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 moreSource§impl<I, O, S> TryInitSans<I, O> for Swhere
S: InitSans<I, O>,
impl<I, O, S> TryInitSans<I, O> for Swhere
S: InitSans<I, O>,
Source§fn ok_map<P, E, T, F>(self, f: F) -> OkMap<Self, T::Next, F>
fn ok_map<P, E, T, F>(self, f: F) -> OkMap<Self, T::Next, F>
Maps
Ok return values through a function that produces an InitSans.Source§fn ok_and_then<P, Q, E, T, F>(self, f: F) -> OkAndThen<Self, T::Next, F>
fn ok_and_then<P, Q, E, T, F>(self, f: F) -> OkAndThen<Self, T::Next, F>
Chains through a function that produces an
InitSans with a Result return type.Source§impl<I, O, S> TrySans<I, O> for Swhere
S: Sans<I, O>,
impl<I, O, S> TrySans<I, O> for Swhere
S: Sans<I, O>,
Source§fn ok_map<P, E, T, F>(self, f: F) -> OkMap<Self, T::Next, F>
fn ok_map<P, E, T, F>(self, f: F) -> OkMap<Self, T::Next, F>
Maps
Ok return values through a function that produces an InitSans.Source§fn ok_and_then<P, Q, E, T, F>(self, f: F) -> OkAndThen<Self, T::Next, F>
fn ok_and_then<P, Q, E, T, F>(self, f: F) -> OkAndThen<Self, T::Next, F>
Chains through a function that produces an
InitSans with a Result return type.