vars/
core.rs

1use crate::{HNext};
2
3pub trait Vars<T>: PushFront<T> + HNext<T> + From<Self::Tuple> + UnCons<T> + TupleIntoIterator<T> {
4    type Tuple;
5    type Cons: HNext<T>;
6}
7
8// pub trait Tuple: UnCons {}
9
10pub trait UnCons<H> {
11    type NextIt;
12    type Tail: UnCons<Self::NextIt>;
13
14    fn uncons(self) -> (Option<H>, Self::Tail);
15}
16
17pub trait UnConsOpt<T> {
18    type Head;
19    type Tail;
20
21    fn uncons_opt(self) -> (Self::Head, Self::Tail);
22}
23
24pub trait UnConsMut {
25    type Head<'h>
26    where
27        Self: 'h;
28    type Tail<'t>
29    where
30        Self: 't;
31
32    fn uncons_mut<'a>(&'a mut self) -> (Self::Head<'a>, Self::Tail<'a>);
33}
34
35pub trait PopFront<E>: Vars<E> {
36    fn pop_front(&mut self) -> E;
37}
38
39pub trait GetFront {
40    type Output<'a>
41    where
42        Self: 'a;
43
44    fn get_front<'b>(&'b self) -> Self::Output<'b>;
45}
46
47pub trait GetFrontMut {
48    type Output<'a>
49    where
50        Self: 'a;
51
52    fn get_front<'b>(&mut self) -> Self::Output<'b>;
53}
54
55pub trait PushFront<E> {
56    type Output;
57
58    fn push_front(self, e: E) -> Self::Output;
59}
60
61pub trait PushBack<E> {
62    type Output;
63
64    fn push_back(self, e: E) -> Self::Output;
65}
66
67pub trait Compose<Init> {
68    type Output;
69
70    fn compose(self, init: Init) -> Self::Output;
71}
72
73pub trait ComposeMut<Init> {
74    type Output;
75
76    fn compose_mut(self, init: Init) -> Self::Output;
77}
78
79pub trait DerefTuple {
80    type Output;
81
82    fn deref(self) -> Self::Output;
83}
84
85pub trait DerefTupleMut {
86    type Output;
87
88    fn deref_mut(&mut self) -> Self::Output;
89}
90
91pub trait TupleIntoIterator<T> {
92    type Output: Iterator<Item = T>;
93    fn into_iter(self) -> Self::Output;
94}
95
96pub trait TupleIterator<T> {
97    type Output: Iterator;
98    fn iter(&self) -> Self::Output;
99}