Lines Matching full:vec

3 //! Implementation of [`Vec`].
68 /// The kernel's [`Vec`] type.
71 /// [`Kmalloc`], [`Vmalloc`] or [`KVmalloc`]), written `Vec<T, A>`.
73 /// For non-zero-sized values, a [`Vec`] will use the given allocator `A` for its allocation. For
76 /// For zero-sized types the [`Vec`]'s pointer must be `dangling_mut::<T>`; no memory is allocated.
78 /// Generally, [`Vec`] consists of a pointer that represents the vector's backing buffer, the
83 /// A [`Vec`] can be deconstructed into and (re-)constructed from its previously named raw parts
86 /// [`Vec`]'s backing buffer gets, if required, automatically increased (re-allocated) when elements
104 pub struct Vec<T, A: Allocator> { struct
115 /// Type alias for [`Vec`] with a [`Kmalloc`] allocator. argument
126 pub type KVec<T> = Vec<T, Kmalloc>;
128 /// Type alias for [`Vec`] with a [`Vmalloc`] allocator.
139 pub type VVec<T> = Vec<T, Vmalloc>;
141 /// Type alias for [`Vec`] with a [`KVmalloc`] allocator.
152 pub type KVVec<T> = Vec<T, KVmalloc>;
154 // SAFETY: `Vec` is `Send` if `T` is `Send` because `Vec` owns its elements.
155 unsafe impl<T, A> Send for Vec<T, A> implementation
162 // SAFETY: `Vec` is `Sync` if `T` is `Sync` because `Vec` owns its elements.
163 unsafe impl<T, A> Sync for Vec<T, A> implementation
170 impl<T, A> Vec<T, A> impl
281 /// Creates a new, empty `Vec<T, A>`.
286 // INVARIANT: Since this is a new, empty `Vec` with no backing memory yet, in new()
312 /// Appends an element to the back of the [`Vec`] instance.
333 /// Appends an element to the back of the [`Vec`] instance without reallocating.
358 /// Appends an element to the back of the [`Vec`] instance without reallocating.
375 /// Inserts an element at the given index in the [`Vec`] instance.
411 // INVARIANT: This breaks the Vec invariants by making `index` contain an invalid element, in insert_within_capacity()
416 // INVARIANT: This restores the Vec invariants. in insert_within_capacity()
478 // INVARIANT: After this call, the invalid value is at the last slot, so the Vec invariants in remove()
491 /// Creates a new [`Vec`] instance with at least the given capacity.
502 let mut v = Vec::new(); in with_capacity()
509 /// Creates a `Vec<T, A>` from a pointer, a length and a capacity using the allocator `A`.
548 /// It is also valid to create an empty `Vec` passing a dangling pointer for `ptr` and zero for
571 /// Consumes the `Vec<T, A>` and returns its raw components `pointer`, `length` and `capacity`.
574 /// will stay alive indefinitely. Use [`Vec::from_raw_parts`] to recover the [`Vec`], drop the
738 impl<T: Clone, A: Allocator> Vec<T, A> { implementation
764 /// Pushes clones of the elements of slice into the [`Vec`] instance.
794 /// Create a new `Vec<T, A>` and extend it by `n` clones of `value`.
803 /// Resizes the [`Vec`] so that `len` is equal to `new_len`.
805 /// If `new_len` is smaller than `len`, the `Vec` is [`Vec::truncate`]d.
831 impl<T, A> Drop for Vec<T, A> implementation
851 impl<T, A, const N: usize> From<Box<[T; N], A>> for Vec<T, A> implementation
855 fn from(b: Box<[T; N], A>) -> Vec<T, A> { in from()
865 unsafe { Vec::from_raw_parts(ptr.cast(), len, len) }
869 impl<T, A: Allocator> Default for Vec<T, A> { implementation
876 impl<T: fmt::Debug, A: Allocator> fmt::Debug for Vec<T, A> { implementation
882 impl<T, A> Deref for Vec<T, A> implementation
896 impl<T, A> DerefMut for Vec<T, A> implementation
925 impl<T, A> Borrow<[T]> for Vec<T, A> implementation
951 impl<T, A> BorrowMut<[T]> for Vec<T, A> implementation
960 impl<T: Eq, A> Eq for Vec<T, A> where A: Allocator {} implementation
962 impl<T, I: SliceIndex<[T]>, A> Index<I> for Vec<T, A> implementation
974 impl<T, I: SliceIndex<[T]>, A> IndexMut<I> for Vec<T, A> implementation
999 [A1: Allocator, A2: Allocator] Vec<T, A1>, Vec<U, A2>,
1000 [A: Allocator] Vec<T, A>, &[U],
1001 [A: Allocator] Vec<T, A>, &mut [U],
1002 [A: Allocator] &[T], Vec<U, A>,
1003 [A: Allocator] &mut [T], Vec<U, A>,
1004 [A: Allocator] Vec<T, A>, [U],
1005 [A: Allocator] [T], Vec<U, A>,
1006 [A: Allocator, const N: usize] Vec<T, A>, [U; N],
1007 [A: Allocator, const N: usize] Vec<T, A>, &[U; N],
1010 impl<'a, T, A> IntoIterator for &'a Vec<T, A> implementation
1022 impl<'a, T, A: Allocator> IntoIterator for &'a mut Vec<T, A> implementation
1041 /// let mut vec = VVec::<u8>::new();
1043 /// assert!(vec.page_iter().next().is_none());
1045 /// vec.reserve(PAGE_SIZE, GFP_KERNEL)?;
1047 /// let page = vec.page_iter().next().expect("At least one page should be available.\n");
1071 /// An [`Iterator`] implementation for [`Vec`] that moves elements out of a vector.
1073 /// This structure is created by the [`Vec::into_iter`] method on [`Vec`] (provided by the
1105 /// Same as `Iterator::collect` but specialized for `Vec`'s `IntoIter`.
1127 /// case where `I::IntoIter` equals `Vec`'s `IntoIter` type.
1136 /// `Vec` again.
1140 pub fn collect(self, flags: Flags) -> Vec<T, A> { in collect()
1189 // `Vec`. in collect()
1190 unsafe { Vec::from_raw_parts(ptr, len, cap) } in collect()
1268 impl<T, A> IntoIterator for Vec<T, A> implementation
1275 /// Consumes the `Vec<T, A>` and creates an `Iterator`, which moves each value out of the
1325 pub struct DrainAll<'vec, T> {
1326 elements: slice::IterMut<'vec, T>,
1329 impl<'vec, T> Iterator for DrainAll<'vec, T> {
1343 impl<'vec, T> Drop for DrainAll<'vec, T> {