1use alloc::vec::Vec;
2
3pub trait Vector<T> {
7 fn clear(&mut self);
8 fn len(&self) -> usize;
9 fn push(&mut self, value: T);
10 fn slice(&self) -> &[T];
11 fn slice_mut(&mut self) -> &mut [T];
12}
13
14impl<T> Vector<T> for Vec<T> {
15 fn clear(&mut self) {
16 Vec::clear(self);
17 }
18
19 fn len(&self) -> usize {
20 Vec::len(self)
21 }
22
23 fn push(&mut self, value: T) {
24 Vec::push(self, value);
25 }
26
27 fn slice(&self) -> &[T] {
28 self
29 }
30
31 fn slice_mut(&mut self) -> &mut [T] {
32 self
33 }
34}
35
36#[cfg(feature = "bumpalo")]
37impl<T> Vector<T> for bumpalo::collections::Vec<'_, T> {
38 fn clear(&mut self) {
39 bumpalo::collections::Vec::clear(self);
40 }
41
42 fn len(&self) -> usize {
43 bumpalo::collections::Vec::len(self)
44 }
45
46 fn push(&mut self, value: T) {
47 bumpalo::collections::Vec::push(self, value);
48 }
49
50 fn slice(&self) -> &[T] {
51 self
52 }
53
54 fn slice_mut(&mut self) -> &mut [T] {
55 self
56 }
57}