non_empty_iter/
adapter.rs1use crate::non_empty::NonEmptyIterator;
4
5#[derive(Debug, Clone)]
11#[must_use = "non-empty iterators are lazy and do nothing unless consumed"]
12pub struct NonEmptyAdapter<I: IntoIterator> {
13 iterable: I,
14}
15
16impl<I: IntoIterator> NonEmptyAdapter<I> {
17 pub const unsafe fn new(iterable: I) -> Self {
23 Self { iterable }
24 }
25}
26
27impl<I: IntoIterator> IntoIterator for NonEmptyAdapter<I> {
28 type Item = I::Item;
29
30 type IntoIter = I::IntoIter;
31
32 fn into_iter(self) -> Self::IntoIter {
33 self.iterable.into_iter()
34 }
35}
36
37unsafe impl<I: IntoIterator> NonEmptyIterator for NonEmptyAdapter<I> {}