Lines Matching full:capacity
75 /// capacity of the vector (the number of elements that currently fit into the vector), its length
93 /// without re-allocation. For ZSTs `self.layout`'s capacity is zero. However, it is legal for the
102 /// Note: This isn't quite the same as `Self::capacity`, which in contrast returns the number of
175 pub fn capacity(&self) -> usize { in capacity() function
193 /// - `new_len` must be less than or equal to [`Self::capacity`].
198 debug_assert!(new_len <= self.capacity()); in set_len()
251 // - `layout` is an empty `ArrayLayout` (zero capacity) in new()
262 /// Returns a slice of `MaybeUninit<T>` for the remaining spare capacity of the vector.
265 // - `self.len` is smaller than `self.capacity` and hence, the resulting pointer is in spare_capacity_mut()
270 // SAFETY: The memory between `self.len` and `self.capacity` is guaranteed to be allocated in spare_capacity_mut()
272 unsafe { slice::from_raw_parts_mut(ptr, self.capacity() - self.len) } in spare_capacity_mut()
292 // - `self.len` is smaller than `self.capacity` and hence, the resulting pointer is in push()
302 // by 1. We also know that the new length is <= capacity because of the previous call to in push()
308 /// Creates a new [`Vec`] instance with at least the given capacity.
315 /// assert!(v.capacity() >= 20);
318 pub fn with_capacity(capacity: usize, flags: Flags) -> Result<Self, AllocError> { in with_capacity()
321 v.reserve(capacity, flags)?; in with_capacity()
326 /// Creates a `Vec<T, A>` from a pointer, a length and a capacity using the allocator `A`.
360 /// - `ptr` must point to memory with a size of at least `size_of::<T>() * capacity` bytes.
362 /// - `length` must be less than or equal to `capacity`.
367 pub unsafe fn from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Self { in from_raw_parts()
371 // SAFETY: By the safety requirements of this function, `capacity * size_of::<T>()` is in from_raw_parts()
373 unsafe { ArrayLayout::new_unchecked(capacity) } in from_raw_parts()
388 /// Consumes the `Vec<T, A>` and returns its raw components `pointer`, `length` and `capacity`.
396 let capacity = me.capacity(); in into_raw_parts() localVariable
398 (ptr, len, capacity) in into_raw_parts()
401 /// Ensures that the capacity exceeds the length by at least `additional` elements.
410 /// let cap = v.capacity();
414 /// let new_cap = v.capacity();
421 let cap = self.capacity(); in reserve()
428 // The capacity is already `usize::MAX` for ZSTs, we can't go higher. in reserve()
479 // - `self.len() + n < self.capacity()` due to the call to reserve above, in extend_with()
510 // - `self.len() + other.len() <= self.capacity()` is guaranteed by the preceding `reserve` in extend_from_slice()
786 // - `cap` is either the original capacity or, after shrinking the buffer, equal to `len`. in collect()