Lines Matching full:slice

3 //! Utilities for the slice primitive type.
5 //! *[See also the slice primitive type](slice).*
8 //! using a certain function. For example, `slice.iter()` yields an [`Iter`].
10 //! A few functions are provided to create a slice from a value reference
25 use core::slice::sort;
39 pub use core::slice::range;
41 pub use core::slice::ArrayChunks;
43 pub use core::slice::ArrayChunksMut;
45 pub use core::slice::ArrayWindows;
47 pub use core::slice::EscapeAscii;
49 pub use core::slice::SliceIndex;
51 pub use core::slice::{from_mut, from_ref};
53 pub use core::slice::{from_mut_ptr_range, from_ptr_range};
55 pub use core::slice::{from_raw_parts, from_raw_parts_mut};
57 pub use core::slice::{Chunks, Windows};
59 pub use core::slice::{ChunksExact, ChunksExactMut};
61 pub use core::slice::{ChunksMut, Split, SplitMut};
63 pub use core::slice::{GroupBy, GroupByMut};
65 pub use core::slice::{Iter, IterMut};
67 pub use core::slice::{RChunks, RChunksExact, RChunksExactMut, RChunksMut};
69 pub use core::slice::{RSplit, RSplitMut};
71 pub use core::slice::{RSplitN, RSplitNMut, SplitN, SplitNMut};
73 pub use core::slice::{SplitInclusive, SplitInclusiveMut};
76 // Basic slice extension methods
91 // `core::slice::SliceExt` - we need to supply these functions for the
179 /// Sorts the slice.
185 /// See [`sort_unstable`](slice::sort_unstable).
191 /// It is designed to be very fast in cases where the slice is nearly sorted, or consists of
216 /// Sorts the slice with a comparator function.
220 /// The comparator function must define a total ordering for the elements in the slice. If
228 /// `partial_cmp` as our sort function when we know the slice doesn't contain a `NaN`.
238 /// See [`sort_unstable_by`](slice::sort_unstable_by).
244 /// It is designed to be very fast in cases where the slice is nearly sorted, or consists of
272 /// Sorts the slice with a key extraction function.
278 /// basic operations), [`sort_by_cached_key`](slice::sort_by_cached_key) is likely to be
283 /// See [`sort_unstable_by_key`](slice::sort_unstable_by_key).
289 /// It is designed to be very fast in cases where the slice is nearly sorted, or consists of
315 /// Sorts the slice with a key extraction function.
326 /// basic operations), [`sort_by_key`](slice::sort_by_key) is likely to be
338 /// length of the slice.
361 ($t:ty, $slice:ident, $f:ident) => {{ in sort_by_cached_key()
363 $slice.iter().map($f).enumerate().map(|(i, k)| (k, i as $t)).collect(); in sort_by_cached_key()
365 // stable with respect to the original slice. We use `sort_unstable` here because in sort_by_cached_key()
368 for i in 0..$slice.len() { in sort_by_cached_key()
374 $slice.swap(i, index as usize); in sort_by_cached_key()
468 /// Creates a vector by copying a slice `n` times.
549 /// Flattens a slice of `T` into a single value `Self::Output`.
566 /// Flattens a slice of `T` into a single value `Self::Output`, placing a
585 /// Flattens a slice of `T` into a single value `Self::Output`, placing a
608 /// Returns a vector containing a copy of this slice where each byte
616 /// [`make_ascii_uppercase`]: slice::make_ascii_uppercase
629 /// Returns a vector containing a copy of this slice where each byte
637 /// [`make_ascii_lowercase`]: slice::make_ascii_lowercase
655 /// Helper trait for [`[T]::concat`](slice::concat).
663 /// --> library/alloc/src/slice.rs:608:6
690 /// Implementation of [`[T]::concat`](slice::concat)
692 fn concat(slice: &Self) -> Self::Output; in concat()
695 /// Helper trait for [`[T]::join`](slice::join)
702 /// Implementation of [`[T]::join`](slice::join)
704 fn join(slice: &Self, sep: Separator) -> Self::Output; in join()
712 fn concat(slice: &Self) -> Vec<T> { in concat()
713 let size = slice.iter().map(|slice| slice.borrow().len()).sum(); in concat()
715 for v in slice { in concat()
727 fn join(slice: &Self, sep: &T) -> Vec<T> { in join()
728 let mut iter = slice.iter(); in join()
733 let size = slice.iter().map(|v| v.borrow().len()).sum::<usize>() + slice.len() - 1; in join()
750 fn join(slice: &Self, sep: &[T]) -> Vec<T> { in join()
751 let mut iter = slice.iter(); in join()
757 slice.iter().map(|v| v.borrow().len()).sum::<usize>() + sep.len() * (slice.len() - 1); in join()