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