wiwi_chain/vec.rs
1use crate::prelude_internal::*;
2use core::cmp::Ordering;
3use core::mem::MaybeUninit;
4
5crate::impl_chain_conversions!([T] Vec<T>);
6
7crate::chain_fns! {
8 impl [T] Vec<T>;
9
10 doc "[T]::align_to" ("slice::align_to")
11 unsafe fn align_to[U](inner, cb: impl FnOnce((&[T], &[U], &[T]))) {
12 // SAFETY: caller promises to uphold safety invariants
13 unsafe { cb(inner.align_to()) }
14 }
15
16 doc "[T]::align_to_mut" ("slice::align_to_mut")
17 unsafe fn align_to_mut[U](
18 inner,
19 cb: impl FnOnce((&mut [T], &mut [U], &mut [T]))
20 ) {
21 // SAFETY: caller promises to uphold safety invariants
22 unsafe { cb(inner.align_to_mut()) }
23 }
24
25 doc "Vec::append"
26 fn append(inner, other: &mut impl ChainConversions<Inner = Vec<T>>) {
27 inner.append(other.as_inner_mut())
28 }
29
30 doc "[T]::binary_search" ("slice::binary_search")
31 fn binary_search(
32 inner,
33 x: &T,
34 out: impl Output<Result<usize, usize>>
35 ) where {
36 T: Ord
37 } {
38 out.write(inner.binary_search(x))
39 }
40
41 doc "[T]::binary_search_by" ("slice::binary_search_by")
42 fn binary_search_by(
43 inner,
44 f: impl FnMut(&T) -> Ordering,
45 out: impl Output<Result<usize, usize>>
46 ) {
47 out.write(inner.binary_search_by(f))
48 }
49
50 doc "[T]::binary_search_by_key" ("slice::binary_search_by_key")
51 fn binary_search_by_key[B](
52 inner,
53 b: &B,
54 f: impl FnMut(&T) -> B,
55 out: impl Output<Result<usize, usize>>
56 ) where {
57 B: Ord
58 } {
59 out.write(inner.binary_search_by_key(b, f))
60 }
61
62 doc "Vec::capacity"
63 fn capacity(inner, out: impl Output<usize>) {
64 out.write(inner.capacity())
65 }
66
67 doc "Vec::clear"
68 fn clear(inner) {
69 inner.clear()
70 }
71
72 // todo concat trait is unstable
73 // fn concat[Item](inner, out: impl Output<<[T] as std::slice::Concat<Item>>::Output>)
74 // where {
75 // [T]: std::slice::Concat<Item>,
76 // Item: ?Sized
77 // } {
78 // out.write(inner.concat())
79 // }
80
81 doc "Vec::dedup"
82 fn dedup(inner)
83 where {
84 T: PartialEq
85 } {
86 inner.dedup()
87 }
88
89 doc "Vec::dedup_by"
90 fn dedup_by(
91 inner,
92 same_bucket: impl FnMut(&mut T, &mut T) -> bool
93 ) {
94 inner.dedup_by(same_bucket)
95 }
96
97 doc "Vec::dedup_by_key"
98 fn dedup_by_key[K](inner, key: impl FnMut(&mut T) -> K)
99 where {
100 K: PartialEq
101 } {
102 inner.dedup_by_key(key)
103 }
104
105 doc "[T]::fill" ("slice::fill")
106 fn fill(inner, value: T) where {
107 T: Clone
108 } {
109 inner.fill(value)
110 }
111
112 doc "[T]::fill_with" ("slice::fill_with")
113 fn fill_with(inner, f: impl FnMut() -> T) {
114 inner.fill_with(f)
115 }
116
117 doc "Vec::insert"
118 fn insert(inner, index: usize, element: T) {
119 inner.insert(index, element)
120 }
121
122 doc "Vec::is_empty"
123 fn is_empty(inner, out: impl Output<bool>) {
124 out.write(inner.is_empty())
125 }
126
127 doc "Vec::len"
128 fn len(inner, out: impl Output<usize>) {
129 out.write(inner.len())
130 }
131
132 doc "Vec::pop"
133 fn pop(inner, out: impl Output<Option<T>>) {
134 out.write(inner.pop())
135 }
136
137 // todo: msrv 1.86
138 // fn pop_if(
139 // inner,
140 // predicate: impl FnOnce(&mut T) -> bool,
141 // out: impl Output<Option<T>>
142 // ) => out.write(inner.pop_if(predicate));
143
144 doc "Vec::push"
145 fn push(inner, value: T) {
146 inner.push(value)
147 }
148
149 // todo unstable
150 // doc "Vec::push_within_capacity"
151 // fn push_within_capacity(inner, value: T, out: impl Output<Result<(), T>>) {
152 // out.write(inner.push_within_capacity(value))
153 // }
154
155 doc "Vec::remove"
156 fn remove(inner, index: usize, out: impl Output<T>) {
157 out.write(inner.remove(index))
158 }
159
160 doc "Vec::reserve"
161 fn reserve(inner, additional: usize) {
162 inner.reserve(additional)
163 }
164
165 doc "Vec::reserve_exact"
166 fn reserve_exact(inner, additional: usize) {
167 inner.reserve_exact(additional)
168 }
169
170 doc "Vec::resize"
171 fn resize(inner, new_len: usize, value: T)
172 where {
173 T: Clone
174 } {
175 inner.resize(new_len, value)
176 }
177
178 doc "Vec::resize_with"
179 fn resize_with(inner, new_len: usize, f: impl FnMut() -> T) {
180 inner.resize_with(new_len, f)
181 }
182
183 doc "Vec::retain"
184 fn retain(inner, f: impl FnMut(&T) -> bool) {
185 inner.retain(f)
186 }
187
188 doc "Vec::retain_mut"
189 fn retain_mut(inner, f: impl FnMut(&mut T) -> bool) {
190 inner.retain_mut(f)
191 }
192
193 doc "Vec::set_len"
194 unsafe fn set_len(inner, new_len: usize) {
195 // SAFETY: caller promises to uphold safety invariants
196 unsafe { inner.set_len(new_len) }
197 }
198
199 doc "Vec::shrink_to"
200 fn shrink_to(inner, min_capacity: usize) {
201 inner.shrink_to(min_capacity)
202 }
203
204 doc "Vec::shrink_to_fit"
205 fn shrink_to_fit(inner) {
206 inner.shrink_to_fit()
207 }
208
209 doc "[T]::sort" ("slice::sort")
210 fn sort(inner)
211 where {
212 T: Ord
213 } {
214 inner.sort()
215 }
216
217 doc "[T]::sort_by" ("slice::sort_by")
218 fn sort_by(inner, compare: impl FnMut(&T, &T) -> Ordering) {
219 inner.sort_by(compare)
220 }
221
222 doc "[T]::sort_by_key" ("slice::sort_by_key")
223 fn sort_by_key[K](inner, f: impl FnMut(&T) -> K)
224 where {
225 K: Ord
226 } {
227 inner.sort_by_key(f)
228 }
229
230 doc "[T]::sort_by_cached_key" ("slice::sort_by_cached_key")
231 fn sort_by_cached_key[K](inner, f: impl FnMut(&T) -> K)
232 where {
233 K: Ord
234 } {
235 inner.sort_by_cached_key(f)
236 }
237
238 doc "Vec::spare_capacity_mut"
239 fn spare_capacity_mut(inner, cb: impl FnOnce(&mut [MaybeUninit<T>])) {
240 cb(inner.spare_capacity_mut())
241 }
242
243 // allocator
244 // array_chunks
245 // array_chunks_mut
246 // array_windows
247 // as_array
248 // as_array_mut
249 // as_ptr_mut
250 // as_slice_mut
251 // as_non_null
252 // as_ptr
253 // as_slice
254 // drain
255 // extend_from_slice
256 // extend_from_within
257 // extract_if
258 // from_parts
259 // from_parts_in
260 // from_raw_parts
261 // from_raw_parts_in
262 // into_boxed_slice
263 // into_flattened
264 // into_parts
265 // into_parts_with_alloc
266 // into_raw_parts
267 // into_raw_parts_with_alloc
268 // leak
269 // splice
270 // split_at_spare_mut
271 // split_off
272 // swap_remove
273 // truncate
274 // try_reserve
275 // try_reserve_exact
276
277 // as_ascii
278 // as_ascii_unchecked
279 // as_bytes
280 // as_bytes
281 // as_bytes_mut
282 // as_chunks
283 // as_chunks_mut
284 // as_chunks_unchecked
285 // as_chunks_unchecked_mut
286 // as_flattened
287 // as_flattened_mut
288 // as_array_mut
289 // as_ptr_mut
290 // as_ptr_range_mut
291 // as_ptr
292 // as_ptr_range
293 // as_rchunks
294 // as_rchunks_mut
295 // as_simd
296 // as_simd_mut
297 // as_str
298 // assume_init_drop
299 // assume_init_mut
300 // assume_init_ref
301 // binary_search
302 // binary_search_by
303 // binary_search_by_key
304 // chunk_by
305 // chunk_by_mut
306 // chunks
307 // chunks_exact
308 // chunks_exact_mut
309 // chunks_mut
310 // clone_from_slice
311 // concat
312 // connect
313 // contains
314 // copy_from_slice
315 // copy_within
316 // element_offset
317 // ends_with
318 // eq_ignore_ascii_case
319 // escape_ascii
320 // first
321 // first_chunk
322 // first_chunk_mut
323 // first_mut
324 // get
325 // get_disjoint_mut
326 // get_disjoint_unchecked_mut
327 // get_mut
328 // get_unchecked
329 // get_unchecked_mut
330 // is_ascii
331 // is_empty
332 // is_sorted
333 // is_sorted_by
334 // is_sorted_by_key
335 // iter
336 // iter_mut
337 // join
338 // last
339 // last_chunk
340 // last_chunk_mut
341 // last_mut
342 // len
343 // make_ascii_lowercase
344 // make_ascii_uppercase
345 // partition_dedup
346 // partition_dedup_by
347 // partition_dedup_by_key
348 // partition_point
349 // rchunks
350 // rchunks_exact
351 // rchunks_exact_mut
352 // rchunks_mut
353 // repeat
354 // reverse
355 // rotate_left
356 // rotate_right
357 // rsplit
358 // rsplit_mut
359 // rsplit_once
360 // rsplitn
361 // rsplitn_mut
362 // select_nth_unstable
363 // select_nth_unstable_by
364 // select_nth_unstable_by_key
365 // sort_floats
366 // sort_floats
367 // sort_unstable
368 // sort_unstable_by
369 // sort_unstable_by_key
370 // split
371 // split_at
372 // split_at_checked
373 // split_at_mut
374 // split_at_checked_mut
375 // split_at_unchecked_mut
376 // split_at_unchecked
377 // split_first
378 // split_first_chunk
379 // split_first_chunk_mut
380 // split_first_mut
381 // split_inclusive
382 // split_inclusive_mut
383 // split_last
384 // split_last_chunk
385 // split_last_chunk_mut
386 // split_last_mut
387 // split_mut
388 // split_off
389 // split_off_first
390 // split_off_first_mut
391 // split_off_last
392 // split_off_last_mut
393 // split_off_mut
394 // split_once
395 // splitn
396 // splitn_mut
397 // starts_with
398 // strip_prefix
399 // strip_suffix
400 // subslice_range
401 // swap
402 // swap_unchecked
403 // swap_with_slice
404 // to_ascii_lowercase
405 // to_ascii_uppercase
406 // to_vec
407 // to_vec_in
408 // trim_ascii
409 // trim_ascii_end
410 // trim_ascii_start
411 // utf8_chunks
412 // windows
413 // write_clone_of_slice
414 // write_copy_of_slice
415}
416
417/*
418Trait Implementations
419AsMut<Vec<T, A>>
420AsMut<[T]>
421AsRef<Vec<T, A>>
422AsRef<[T]>
423Borrow<[T]>
424BorrowMut<[T]>
425Clone
426Debug
427Default
428Deref
429DerefMut
430DerefPure
431Drop
432Eq
433Extend<&'a T>
434Extend<T>
435From<&'a Vec<T>>
436From<&[T; N]>
437From<&[T]>
438From<&mut [T; N]>
439From<&mut [T]>
440From<&str>
441From<BinaryHeap<T, A>>
442From<Box<[T], A>>
443From<ByteString>
444From<CString>
445From<Cow<'a, [T]>>
446From<String>
447From<Vec<NonZero<u8>>>
448From<Vec<T, A>>
449From<Vec<T, A>>
450From<Vec<T, A>>
451From<Vec<T, A>>
452From<Vec<T, A>>
453From<Vec<T>>
454From<VecDeque<T, A>>
455From<[T; N]>
456FromIterator<T>
457Hash
458Index<I>
459IndexMut<I>
460IntoIterator
461IntoIterator
462IntoIterator
463Ord
464PartialEq<&[U; N]>
465PartialEq<&[U]>
466PartialEq<&mut [U]>
467PartialEq<ByteStr>
468PartialEq<ByteString>
469PartialEq<Vec<U, A2>>
470PartialEq<Vec<U, A>>
471PartialEq<Vec<U, A>>
472PartialEq<Vec<U, A>>
473PartialEq<Vec<U, A>>
474PartialEq<Vec<U, A>>
475PartialEq<Vec<u8>>
476PartialEq<Vec<u8>>
477PartialEq<[U; N]>
478PartialEq<[U]>
479PartialOrd<Vec<T, A2>>
480TryFrom<Vec<T, A>>
481TryFrom<Vec<T>>
482TryFrom<Vec<u8>>
483Write
484*/