1use core::iter;
4
5use crate::non_empty::NonEmptyIterator;
6
7#[derive(Debug, Clone)]
15#[must_use = "non-empty iterators are lazy and do nothing unless consumed"]
16pub struct Fuse<I: NonEmptyIterator> {
17 non_empty: I,
18}
19
20impl<I: NonEmptyIterator> Fuse<I> {
21 pub const fn new(non_empty: I) -> Self {
23 Self { non_empty }
24 }
25}
26
27impl<I: NonEmptyIterator> IntoIterator for Fuse<I> {
28 type Item = I::Item;
29
30 type IntoIter = iter::Fuse<I::IntoIter>;
31
32 fn into_iter(self) -> Self::IntoIter {
33 self.non_empty.into_iter().fuse()
34 }
35}
36
37unsafe impl<I: NonEmptyIterator> NonEmptyIterator for Fuse<I> {}