Trait map_ok::MapOk

source ·
pub trait MapOk<T, E, F, U>: Sized
where 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§

source

type Iter: Iterator<Item = Result<U, E>>

Required Methods§

source

fn map_ok(self, f: F) -> Self::Iter

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<I, T, E, U, F> MapOk<T, E, F, U> for I
where I: Iterator<Item = Result<T, E>>, F: Fn(T) -> U,

§

type Iter = MapOkIter<I, T, E, U, F>