1 2 3 4 5 6 7 8 9 10 11 12
pub trait BoxedIterator<T> { fn boxed(self) -> Box<dyn Iterator<Item = T>>; } impl<I, T> BoxedIterator<T> for I where I: Iterator<Item = T> + 'static, { fn boxed(self) -> Box<dyn Iterator<Item = T>> { Box::new(self) as _ } }