pub trait MapOk<T, E, F, U>: Sizedwhere
F: Fn(T) -> U,{
type Iter: Iterator<Item = Result<U, E>>;
// Required method
fn map_ok(self, f: F) -> Self::Iter;
}Expand description
Represents an iterator that maps the Ok values to another type using the given function.
This trait is implemented for iterators over Result<T, E>, allowing them to transform
the Ok values using a closure.
§Example
use std::iter::Iterator;
use map_ok::MapOkIter;
pub trait MapOk<T, E>: Sized {
fn map_ok<U, F>(self, f: F) -> MapOkIter<Self, T, E, U, F>
where
F: Fn(T) -> U;
}§Implementations
Implementations of this trait must provide an implementation for the map_ok function, which receives
a closure f that takes an Ok value of type T and returns a value of type U. It returns a MapOk
iterator, which will apply the closure to each Ok value encountered during iteration.
Required Associated Types§
Required Methods§
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.