[][src]Trait iter_transpose::IterTranspose

pub trait IterTranspose {
    type Iter: Iterator;
    pub fn transpose_into_iter(self) -> Self::Iter;
}

Provides transpose_into_iter function for the implementing structs.

This trait is implemented for both Option and Result, and it functions as an extension of the API of these two structs. See the crate-level documentation for more information and examples.

Associated Types

type Iter: Iterator[src]

The iterator type produced by transpose_into_iter.

Loading content...

Required methods

pub fn transpose_into_iter(self) -> Self::Iter[src]

If called on an option containing a collection or an iterator, it produces an iterator of options, and similarly for results.

Examples

use iter_transpose::IterTranspose;
assert_eq!(
    Some(vec![1, 2, 3]).transpose_into_iter().take(3).collect::<Vec<_>>(),
    vec![Some(1), Some(2), Some(3)],
);
assert_eq!(
    Result::<Vec<i32>, ()>::Ok(vec![1, 2, 3]).transpose_into_iter().take(3).collect::<Vec<_>>(),
    vec![Result::<i32, ()>::Ok(1), Ok(2), Ok(3)],
);
assert_eq!(
    Option::<Vec<i32>>::None.transpose_into_iter().take(3).collect::<Vec<_>>(),
    vec![None, None, None],
);
assert_eq!(
    Result::<Vec<i32>, ()>::Err(()).transpose_into_iter().take(3).collect::<Vec<_>>(),
    vec![Result::<i32, ()>::Err(()), Err(()), Err(())],
);
Loading content...

Implementations on Foreign Types

impl<I> IterTranspose for Option<I> where
    I: IntoIterator
[src]

type Iter = OptionTransposedIter<I::IntoIter>

impl<I, E> IterTranspose for Result<I, E> where
    I: IntoIterator,
    E: Clone + Debug
[src]

type Iter = ResultTransposedIter<I::IntoIter, E>

Loading content...

Implementors

Loading content...