Created
March 27, 2016 02:43
-
-
Save habnabit/3c09c6d5ac3e70ad11b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait FlattenResultsIterator: Itertools { | |
fn flatten_results<A, E, I>(&mut self) -> Result<Box<Iterator<Item=I>>, E> | |
where Self: Sized + Iterator<Item=Result<A, E>>, | |
A: 'static + IntoIterator<Item=I>, | |
I: 'static, | |
{ | |
self.fold_results( | |
Box::new(iter::empty::<I>()) as Box<Iterator<Item=I>>, | |
|accum, it| Box::new(accum.chain(it)) as Box<Iterator<Item=I>>) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment