stack_array/
vector.rs

1impl<T> crate::Array<T> for std::vec::Vec<T> {
2    #[inline]
3    fn capacity(&self) -> usize {
4        Vec::capacity(self)
5    }
6
7    #[inline]
8    fn truncate(&mut self, len: usize) {
9        Vec::truncate(self, len)
10    }
11
12    #[inline]
13    fn as_ptr(&self) -> *const T {
14        Vec::as_ptr(self)
15    }
16
17    #[inline]
18    fn as_mut_ptr(&mut self) -> *mut T {
19        Vec::as_mut_ptr(self)
20    }
21
22    #[inline]
23    unsafe fn set_len(&mut self, len: usize) {
24        Vec::set_len(self, len)
25    }
26
27    #[inline]
28    fn as_slice(&self) -> &[T] {
29        Vec::as_slice(self)
30    }
31
32    #[inline]
33    fn as_mut_slice(&mut self) -> &mut [T] {
34        Vec::as_mut_slice(self)
35    }
36
37    #[inline]
38    fn swap_remove(&mut self, index: usize) -> T {
39        Vec::swap_remove(self, index)
40    }
41
42    #[inline]
43    fn insert(&mut self, index: usize, element: T) {
44        Vec::insert(self, index, element)
45    }
46
47    #[inline]
48    fn remove(&mut self, index: usize) -> T {
49        Vec::remove(self, index)
50    }
51
52    #[inline]
53    fn retain<F>(&mut self, f: F)
54    where
55        F: FnMut(&T) -> bool,
56    {
57        Vec::retain(self, f)
58    }
59
60    #[inline]
61    fn dedup(&mut self)
62    where
63        T: PartialEq,
64    {
65        Vec::dedup(self)
66    }
67
68    #[inline]
69    fn dedup_by_key<F, K>(&mut self, key: F)
70    where
71        F: FnMut(&mut T) -> K,
72        K: PartialEq,
73    {
74        Vec::dedup_by_key(self, key)
75    }
76
77    #[inline]
78    fn dedup_by<F>(&mut self, same_bucket: F)
79    where
80        F: FnMut(&mut T, &mut T) -> bool,
81    {
82        Vec::dedup_by(self, same_bucket)
83    }
84
85    #[inline]
86    fn push(&mut self, value: T) {
87        Vec::push(self, value)
88    }
89
90    #[inline]
91    fn append(&mut self, other: &mut Self) {
92        Vec::append(self, other)
93    }
94
95    #[inline]
96    fn clear(&mut self) {
97        Vec::clear(self)
98    }
99
100    #[inline]
101    fn len(&self) -> usize {
102        Vec::len(self)
103    }
104
105    #[inline]
106    fn is_empty(&self) -> bool {
107        Vec::is_empty(self)
108    }
109
110    #[inline]
111    fn pop(&mut self) -> Option<T> {
112        Vec::pop(self)
113    }
114
115    // =========================================================================
116    #[inline]
117    fn ensure_capacity(&mut self, new_len: usize) {
118        if new_len > self.capacity() {
119            Vec::reserve(self, new_len - self.len())
120        }
121    }
122}