1pub struct ListSome<F: ListFn> {
2 pub first: F::Item,
3 pub next: F,
4}
5
6pub enum ListState<F: ListFn> {
8 Some(ListSome<F>),
9 End(F::End),
11}
12
13impl<F: ListFn> ListState<F> {
14 pub fn some(first: F::Item, next: F) -> Self {
15 ListState::Some(ListSome { first, next })
16 }
17 pub fn unwrap(self) -> ListSome<F> {
18 match self {
19 ListState::Some(v) => v,
20 ListState::End(_) => panic!(),
21 }
22 }
23}
24
25pub trait ListFn: Sized {
27 type Item;
29 type End;
31 fn next(self) -> ListState<Self>;
33}