@@ -125,88 +125,90 @@ impl<T, const N: usize> ArrayVec<T, N> {
125
125
// Constructors
126
126
127
127
#[inline]
128
- pub fn from_array (array : [T ; N ]) -> Self ;
128
+ pub const fn from_array (array : [T ; N ]) -> Self ;
129
129
130
130
#[inline]
131
- pub fn from_array_and_len (array : [T ; N ], len : usize ) -> Self ;
131
+ pub const fn from_array_and_len (array : [T ; N ], len : usize ) -> Self ;
132
132
133
133
#[inline]
134
134
pub const fn new () -> Self ;
135
135
136
136
// Methods
137
137
138
138
#[inline]
139
- pub fn as_mut_ptr (& mut self ) -> * mut T ;
139
+ pub const fn as_mut_ptr (& mut self ) -> * mut T ;
140
140
141
141
#[inline]
142
142
pub fn as_mut_slice (& mut self ) -> & mut [T ];
143
143
144
144
#[inline]
145
- pub fn as_ptr (& self ) -> * const T ;
145
+ pub const fn as_ptr (& self ) -> * const T ;
146
146
147
147
#[inline]
148
148
pub fn as_slice (& self ) -> & [T ];
149
149
150
150
#[inline]
151
151
pub const fn capacity (& self ) -> usize ;
152
152
153
- pub fn clear (& mut self );
153
+ #[inline]
154
+ pub const fn clear (& mut self );
154
155
155
- pub fn dedup (& mut self );
156
+ pub fn dedup (& mut self )
157
+ where
158
+ T : PartialEq ;
156
159
157
160
pub fn dedup_by <F >(& mut self , same_bucket : F )
158
161
where
159
162
F : FnMut (& mut T , & mut T ) -> bool ;
160
163
161
- pub fn dedup_by_key <F , K >(& mut self , key : F )
164
+ pub fn dedup_by_key <F , K >(& mut self , mut key : F )
162
165
where
163
166
F : FnMut (& mut T ) -> K ,
164
167
K : PartialEq <K >;
165
168
166
- pub fn drain <R >(& mut self , range : R )
169
+ pub fn drain <R >(& mut self , range : R ) -> Option < Drain <' _ , T , N >>
167
170
where
168
171
R : RangeBounds <usize >;
169
172
170
- pub fn extend_from_cloneable_slice (& mut self , other : & [T ]) -> Result <(), & [T ]>
173
+ pub fn extend_from_cloneable_slice <' a > (& mut self , other : & ' a [T ]) -> Result <(), & ' a [T ]>
171
174
where
172
175
T : Clone ;
173
176
174
- pub fn extend_from_copyable_slice (& mut self , other : & [T ]) -> Result <(), & [T ]>
177
+
178
+ pub fn extend_from_copyable_slice <'a >(& mut self , other : & 'a [T ]) -> Result <(), & 'a [T ]>
175
179
where
176
180
T : Copy ;
177
181
178
- pub fn insert (& mut self , _idx : usize , element : T ) -> Result <(), T >;
182
+ pub fn insert (& mut self , idx : usize , element : T ) -> Result <(), T >;
179
183
180
184
#[inline]
181
185
pub const fn is_empty (& self ) -> bool ;
182
-
186
+
183
187
#[inline]
184
188
pub const fn len (& self ) -> usize ;
185
-
189
+
190
+ #[inline]
186
191
pub fn pop (& mut self ) -> Option <T >;
187
192
188
193
#[inline]
189
194
pub fn push (& mut self , element : T ) -> Result <(), T >;
190
195
196
+ #[inline]
191
197
pub fn remove (& mut self , idx : usize ) -> Option <T >;
192
198
193
- pub fn retain <F >(& mut self , f : F )
199
+ pub fn retain <F >(& mut self , mut f : F )
194
200
where
195
201
F : FnMut (& mut T ) -> bool ;
196
202
197
- #[inline]
198
- pub unsafe fn set_len (& mut self , len : usize );
199
-
200
- pub fn splice <R , I >(& mut self , range : R , replace_with : I )
201
- where
202
- I : IntoIterator <Item = T >,
203
- R : RangeBounds <usize >;
203
+ pub fn splice <I , R >(& mut self , range : R , replace_with : I ) -> Option <Splice <'_ , I :: IntoIter , N >>;
204
204
205
- pub fn split_off (& mut self , at : usize ) -> Self ;
205
+ pub fn split_off (& mut self , at : usize ) -> Option < Self > ;
206
206
207
+ #[inline]
207
208
pub fn swap_remove (& mut self , idx : usize ) -> Option <T >;
208
209
209
- pub fn truncate (& mut self , len : usize );
210
+ #[inline]
211
+ pub const fn truncate (& mut self , len : usize );
210
212
}
211
213
```
212
214
@@ -287,7 +289,7 @@ The above description is very similar to what `smallvec` already does.
287
289
Many structures that use ` alloc::vec::Vec ` as the underlying storage can also use stack or hybrid memory, for example, an hypothetical ` GenericString<S> ` , where ` S ` is the storage, could be split into:
288
290
289
291
``` rust
290
- type DynString = GenericString <DynVec <u8 >>;
292
+ type DynString < const N : usize > = GenericString <DynVec <u8 , N >>;
291
293
type HeapString = GenericString <Vec <u8 >>;
292
- type StackString = GenericString <ArrayVec <u8 >>;
294
+ type StackString < const N : usize > = GenericString <ArrayVec <u8 , N >>;
293
295
```
0 commit comments