Debian Codegraph @

src/impls/smallvec.rs

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 use crate::{
2 Capacity, Clear, Collection, CollectionMut, CollectionRef, Get, GetMut, Iter, IterMut, Len,
3 PopBack, PushBack, Remove, Reserve, SimpleCollectionMut, SimpleCollectionRef, WithCapacity,
4 };
5 use smallvec::{Array, SmallVec};
6
7 impl<A: Array> Collection for SmallVec<A> {
8 type Item = A::Item;
9 }
10
11 impl<A: Array> CollectionRef for SmallVec<A> {
12 type ItemRef<'a> = &'a A::Item where Self: 'a;
13
14 crate::covariant_item_ref!();
15 }
16
17 impl<A: Array> CollectionMut for SmallVec<A> {
18 type ItemMut<'a> = &'a mut A::Item where Self: 'a;
19
20 crate::covariant_item_mut!();
21 }
22
23 impl<A: Array> SimpleCollectionRef for SmallVec<A> {
24 crate::simple_collection_ref!();
25 }
26
27 impl<A: Array> SimpleCollectionMut for SmallVec<A> {
28 crate::simple_collection_mut!();
29 }
30
31 impl<A: Array> WithCapacity for SmallVec<A> {
32 #[inline(always)]
33 fn with_capacity(capacity: usize) -> Self {
34 SmallVec::with_capacity(capacity)
35 }
36 }
37
38 impl<A: Array> Len for SmallVec<A> {
39 #[inline(always)]
40 fn len(&self) -> usize {
41 self.len()
42 }
43
44 #[inline(always)]
45 fn is_empty(&self) -> bool {
46 self.is_empty()
47 }
48 }
49
50 impl<A: Array> Capacity for SmallVec<A> {
51 #[inline(always)]
52 fn capacity(&self) -> usize {
53 self.capacity()
54 }
55 }
56
57 impl<A: Array> Reserve for SmallVec<A> {
58 #[inline(always)]
59 fn reserve(&mut self, additional: usize) {
60 self.reserve(additional)
61 }
62 }
63
64 impl<A: Array> Get<usize> for SmallVec<A> {
65 #[inline(always)]
66 fn get(&self, index: usize) -> Option<&A::Item> {
67 self.as_slice().get(index)
68 }
69 }
70
71 impl<A: Array> GetMut<usize> for SmallVec<A> {
72 #[inline(always)]
73 fn get_mut(&mut self, index: usize) -> Option<&mut A::Item> {
74 self.as_mut_slice().get_mut(index)
75 }
76 }
77
78 impl<A: Array> PushBack for SmallVec<A> {
79 type Output = ();
80
81 #[inline(always)]
82 fn push_back(&mut self, t: A::Item) {
83 self.push(t)
84 }
85 }
86
87 impl<A: Array> PopBack for SmallVec<A> {
88 #[inline(always)]
89 fn pop_back(&mut self) -> Option<A::Item> {
90 self.pop()
91 }
92 }
93
94 impl<A: Array> Remove<usize> for SmallVec<A> {
95 #[inline(always)]
96 fn remove(&mut self, index: usize) -> Option<A::Item> {
97 if index < self.len() {
98 Some(self.remove(index))
99 } else {
100 None
101 }
102 }
103 }
104
105 impl<A: Array> Clear for SmallVec<A> {
106 #[inline(always)]
107 fn clear(&mut self) {
108 self.clear()
109 }
110 }
111
112 impl<A: Array> Iter for SmallVec<A> {
113 type Iter<'a> = std::slice::Iter<'a, A::Item> where Self: 'a;
114
115 #[inline(always)]
116 fn iter(&self) -> Self::Iter<'_> {
117 self.as_slice().iter()
118 }
119 }
120
121 impl<A: Array> IterMut for SmallVec<A> {
122 type IterMut<'a> = std::slice::IterMut<'a, A::Item> where Self: 'a;
123
124 #[inline(always)]
125 fn iter_mut(&mut self) -> Self::IterMut<'_> {
126 self.as_mut_slice().iter_mut()
127 }
128 }