transfer commit
This commit is contained in:
@@ -6,31 +6,31 @@ pub type BoxedIter<'a, T> = Box<dyn Iterator<Item = T> + 'a>;
|
||||
pub type BoxedIterIter<'a, T> = BoxedIter<'a, BoxedIter<'a, T>>;
|
||||
/// BoxedIter of a single element
|
||||
pub fn box_once<'a, T: 'a>(t: T) -> BoxedIter<'a, T> {
|
||||
Box::new(iter::once(t))
|
||||
Box::new(iter::once(t))
|
||||
}
|
||||
/// BoxedIter of no elements
|
||||
pub fn box_empty<'a, T: 'a>() -> BoxedIter<'a, T> {
|
||||
Box::new(iter::empty())
|
||||
Box::new(iter::empty())
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! box_chain {
|
||||
($curr:expr) => {
|
||||
Box::new($curr) as BoxedIter<_>
|
||||
};
|
||||
($curr:expr, $($rest:expr),*) => {
|
||||
Box::new($curr$(.chain($rest))*) as $crate::utils::iter::BoxedIter<_>
|
||||
};
|
||||
($curr:expr) => {
|
||||
Box::new($curr) as BoxedIter<_>
|
||||
};
|
||||
($curr:expr, $($rest:expr),*) => {
|
||||
Box::new($curr$(.chain($rest))*) as $crate::utils::iter::BoxedIter<_>
|
||||
};
|
||||
}
|
||||
|
||||
pub fn box_flatten<'a, T: 'a, I: 'a, J: 'a>(i: I) -> BoxedIter<'a, T>
|
||||
where
|
||||
J: Iterator<Item = T>,
|
||||
I: Iterator<Item = J>,
|
||||
J: Iterator<Item = T>,
|
||||
I: Iterator<Item = J>,
|
||||
{
|
||||
Box::new(i.flatten())
|
||||
Box::new(i.flatten())
|
||||
}
|
||||
pub fn into_boxed_iter<'a, T: 'a>(t: T) -> BoxedIter<'a, <T as IntoIterator>::Item>
|
||||
where T: IntoIterator {
|
||||
Box::new(t.into_iter())
|
||||
Box::new(t.into_iter())
|
||||
}
|
||||
Reference in New Issue
Block a user