1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use arrayvec::ArrayVec;
use core::{marker::Destruct, ops};
#[const_trait]
pub trait VecLike:
~const ops::Deref<Target = [<Self as VecLike>::Element]> + ~const ops::DerefMut
{
type Element;
fn is_empty(&self) -> bool;
fn len(&self) -> usize;
fn pop(&mut self) -> Option<Self::Element>;
fn push(&mut self, x: Self::Element);
}
impl<T: ~const Destruct, const N: usize> VecLike for ArrayVec<T, N> {
type Element = T;
fn is_empty(&self) -> bool {
self.is_empty()
}
fn len(&self) -> usize {
self.len()
}
fn pop(&mut self) -> Option<Self::Element> {
self.pop()
}
fn push(&mut self, x: Self::Element) {
self.push(x)
}
}
impl<T: ~const Destruct> const VecLike for crate::utils::ComptimeVec<T> {
type Element = T;
fn is_empty(&self) -> bool {
(**self).is_empty()
}
fn len(&self) -> usize {
(**self).len()
}
fn pop(&mut self) -> Option<Self::Element> {
(*self).pop()
}
fn push(&mut self, x: Self::Element) {
(*self).push(x)
}
}
#[cfg(test)]
impl<T> VecLike for Vec<T> {
type Element = T;
fn is_empty(&self) -> bool {
self.is_empty()
}
fn len(&self) -> usize {
self.len()
}
fn pop(&mut self) -> Option<Self::Element> {
self.pop()
}
fn push(&mut self, x: Self::Element) {
self.push(x)
}
}