pub trait SequenceResultExt<'gc, I, E>: Sized + Sequence<'gc, Output = Result<I, E>> {
// Provided methods
fn map_ok<F, R>(self, f: F) -> MapOk<Self, F>
where F: 'static + FnOnce(I) -> R { ... }
fn map_ok_with<C, F, R>(self, c: C, f: F) -> MapOkWith<Self, C, F>
where F: 'static + FnOnce(C, I) -> R { ... }
fn map_err<F, R>(self, f: F) -> MapError<Self, F>
where F: 'static + FnOnce(E) -> R { ... }
fn and_then<F, R>(self, f: F) -> AndThen<Self, F, I>
where I: Collect,
F: 'static + FnOnce(MutationContext<'gc, '_>, I) -> Result<R, E> { ... }
fn and_then_with<C, F, R>(self, c: C, f: F) -> AndThenWith<Self, C, F, I>
where C: Collect,
I: Collect,
F: 'static + FnOnce(MutationContext<'gc, '_>, C, I) -> Result<R, E> { ... }
fn and_chain<F, R, I2>(self, f: F) -> FlattenOk<AndThen<Self, F, I>, R>
where I: Collect,
F: 'static + FnOnce(MutationContext<'gc, '_>, I) -> Result<R, E>,
R: Sequence<'gc, Output = Result<I2, E>> { ... }
fn and_chain_with<C, F, R, I2>(
self,
c: C,
f: F,
) -> FlattenOk<AndThenWith<Self, C, F, I>, R>
where C: Collect,
I: Collect,
F: 'static + FnOnce(MutationContext<'gc, '_>, C, I) -> Result<R, E>,
R: Sequence<'gc, Output = Result<I2, E>> { ... }
fn flatten_ok<I2>(self) -> FlattenOk<Self, I>
where I: Sequence<'gc, Output = Result<I2, E>> { ... }
}
Expand description
Extension trait for Sequences
producing a Result
that provides useful combinator methods.
Provided Methods§
Sourcefn map_ok<F, R>(self, f: F) -> MapOk<Self, F>where
F: 'static + FnOnce(I) -> R,
fn map_ok<F, R>(self, f: F) -> MapOk<Self, F>where
F: 'static + FnOnce(I) -> R,
Map a function over the result of this sequence if it is successful.
Similarly to SequenceExt::map
, this function is run in the same call to Sequence::step
.
Sourcefn map_ok_with<C, F, R>(self, c: C, f: F) -> MapOkWith<Self, C, F>where
F: 'static + FnOnce(C, I) -> R,
fn map_ok_with<C, F, R>(self, c: C, f: F) -> MapOkWith<Self, C, F>where
F: 'static + FnOnce(C, I) -> R,
Equivalent to SequenceResultExt::map_ok
, but takes a context parameter.
Sourcefn map_err<F, R>(self, f: F) -> MapError<Self, F>where
F: 'static + FnOnce(E) -> R,
fn map_err<F, R>(self, f: F) -> MapError<Self, F>where
F: 'static + FnOnce(E) -> R,
Map a function over the error result of this sequence, if it errors.
Similarly to SequenceExt::map
, this function is run in the same call to Sequence::step
.
Sourcefn and_then<F, R>(self, f: F) -> AndThen<Self, F, I>
fn and_then<F, R>(self, f: F) -> AndThen<Self, F, I>
Execute another sequence step after this sequence completes successfully.
Similar to SequenceExt::then
but only calls the given function when this sequence
completes successfully.
Sourcefn and_then_with<C, F, R>(self, c: C, f: F) -> AndThenWith<Self, C, F, I>
fn and_then_with<C, F, R>(self, c: C, f: F) -> AndThenWith<Self, C, F, I>
Equivalent to SequenceResultExt::and_then
, but calls the function with the given context
parameter.
Sourcefn and_chain<F, R, I2>(self, f: F) -> FlattenOk<AndThen<Self, F, I>, R>
fn and_chain<F, R, I2>(self, f: F) -> FlattenOk<AndThen<Self, F, I>, R>
Call a function on the result of this sequence, producing a new sequence to run.
Similar to SequenceExt::chain
but only calls the given function when this sequence
completes successfully.
Sourcefn and_chain_with<C, F, R, I2>(
self,
c: C,
f: F,
) -> FlattenOk<AndThenWith<Self, C, F, I>, R>
fn and_chain_with<C, F, R, I2>( self, c: C, f: F, ) -> FlattenOk<AndThenWith<Self, C, F, I>, R>
Equivalent to SequenceResultExt::and_then
, but calls the function with the given context
parameter.
Sourcefn flatten_ok<I2>(self) -> FlattenOk<Self, I>
fn flatten_ok<I2>(self) -> FlattenOk<Self, I>
Similar to SequenceExt::flatten
, but this sequence must result in an Ok(next_sequence)
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.