Lines Matching full:capacity

72 /// capacity of the vector (the number of elements that currently fit into the vector), its length
90 /// without re-allocation. For ZSTs `self.layout`'s capacity is zero. However, it is legal for the
99 /// Note: This isn't quite the same as `Self::capacity`, which in contrast returns the number of
172 pub fn capacity(&self) -> usize { in capacity() function
190 /// - `new_len` must be less than or equal to [`Self::capacity`].
195 debug_assert!(new_len <= self.capacity()); in set_len()
248 // - `layout` is an empty `ArrayLayout` (zero capacity) in new()
259 /// Returns a slice of `MaybeUninit<T>` for the remaining spare capacity of the vector.
262 // - `self.len` is smaller than `self.capacity` and hence, the resulting pointer is in spare_capacity_mut()
267 // SAFETY: The memory between `self.len` and `self.capacity` is guaranteed to be allocated in spare_capacity_mut()
269 unsafe { slice::from_raw_parts_mut(ptr, self.capacity() - self.len) } in spare_capacity_mut()
289 // - `self.len` is smaller than `self.capacity` and hence, the resulting pointer is in push()
299 // by 1. We also know that the new length is <= capacity because of the previous call to in push()
305 /// Creates a new [`Vec`] instance with at least the given capacity.
312 /// assert!(v.capacity() >= 20);
315 pub fn with_capacity(capacity: usize, flags: Flags) -> Result<Self, AllocError> { in with_capacity()
318 v.reserve(capacity, flags)?; in with_capacity()
323 /// Creates a `Vec<T, A>` from a pointer, a length and a capacity using the allocator `A`.
357 /// - `ptr` must point to memory with a size of at least `size_of::<T>() * capacity` bytes.
359 /// - `length` must be less than or equal to `capacity`.
364 pub unsafe fn from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Self { in from_raw_parts()
368 // SAFETY: By the safety requirements of this function, `capacity * size_of::<T>()` is in from_raw_parts()
370 unsafe { ArrayLayout::new_unchecked(capacity) } in from_raw_parts()
385 /// Consumes the `Vec<T, A>` and returns its raw components `pointer`, `length` and `capacity`.
393 let capacity = me.capacity(); in into_raw_parts() localVariable
395 (ptr, len, capacity) in into_raw_parts()
398 /// Ensures that the capacity exceeds the length by at least `additional` elements.
407 /// let cap = v.capacity();
411 /// let new_cap = v.capacity();
418 let cap = self.capacity(); in reserve()
425 // The capacity is already `usize::MAX` for ZSTs, we can't go higher. in reserve()
476 // - `self.len() + n < self.capacity()` due to the call to reserve above, in extend_with()
507 // - `self.len() + other.len() <= self.capacity()` is guaranteed by the preceding `reserve` in extend_from_slice()
783 // - `cap` is either the original capacity or, after shrinking the buffer, equal to `len`. in collect()