lunar-lib 0.9.0

Common utilities for lunar applications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
pub trait IteratorExtensions: Iterator + Sized {
    fn try_map<U, E, F>(self, f: F) -> Result<impl Iterator<Item = U>, E>
    where
        F: FnMut(Self::Item) -> Result<U, E>,
    {
        Ok(self.map(f).collect::<Result<Vec<U>, E>>()?.into_iter())
    }

    fn to_vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<I: Iterator + Sized> IteratorExtensions for I {}