Lines Matching full:capacity

39 /// * Catches all overflows in capacity computations (promotes them to "capacity overflow" panics).
44 /// * Uses the excess returned from the allocator to use the largest available capacity.
50 /// Note that the excess of a zero-sized types is always infinite, so `capacity()` always returns
52 /// `Box<[T]>`, since `capacity()` won't yield the length.
70 /// `RawVec` with capacity `0`. If `T` is zero-sized, then it makes a
71 /// `RawVec` with capacity `usize::MAX`. Useful for implementing
79 /// capacity and alignment requirements for a `[T; capacity]`. This is
80 /// equivalent to calling `RawVec::new` when `capacity` is `0` or `T` is
82 /// *not* get a `RawVec` with the requested capacity.
86 /// Panics if the requested capacity exceeds `isize::MAX` bytes.
94 pub fn with_capacity(capacity: usize) -> Self { in with_capacity()
95 Self::with_capacity_in(capacity, Global) in with_capacity()
102 pub fn with_capacity_zeroed(capacity: usize) -> Self { in with_capacity_zeroed()
103 Self::with_capacity_zeroed_in(capacity, Global) in with_capacity_zeroed()
132 pub fn with_capacity_in(capacity: usize, alloc: A) -> Self { in with_capacity_in()
133 Self::allocate_in(capacity, AllocInit::Uninitialized, alloc) in with_capacity_in()
140 pub fn with_capacity_zeroed_in(capacity: usize, alloc: A) -> Self { in with_capacity_zeroed_in()
141 Self::allocate_in(capacity, AllocInit::Zeroed, alloc) in with_capacity_zeroed_in()
151 /// * `len` must be greater than or equal to the most recently requested capacity, and
152 /// * `len` must be less than or equal to `self.capacity()`.
154 /// Note, that the requested capacity and `self.capacity()` could differ, as
159 len <= self.capacity(), in into_box()
160 "`len` must be smaller than or equal to `self.capacity()`" in into_box()
171 fn allocate_in(capacity: usize, init: AllocInit, alloc: A) -> Self { in allocate_in()
172 // Don't allocate here because `Drop` will not deallocate when `capacity` is 0. in allocate_in()
173 if mem::size_of::<T>() == 0 || capacity == 0 { in allocate_in()
178 let layout = match Layout::array::<T>(capacity) { in allocate_in()
196 // matches the size requested. If that ever changes, the capacity in allocate_in()
200 cap: capacity, in allocate_in()
206 /// Reconstitutes a `RawVec` from a pointer, capacity, and allocator.
211 /// `capacity`.
212 /// The `capacity` cannot exceed `isize::MAX` for sized types. (only a concern on 32-bit
213 /// systems). ZST vectors may have a capacity up to `usize::MAX`.
214 /// If the `ptr` and `capacity` come from a `RawVec` created via `alloc`, then this is
217 pub unsafe fn from_raw_parts_in(ptr: *mut T, capacity: usize, alloc: A) -> Self { in from_raw_parts_in()
218 Self { ptr: unsafe { Unique::new_unchecked(ptr) }, cap: capacity, alloc } in from_raw_parts_in()
222 /// `Unique::dangling()` if `capacity == 0` or `T` is zero-sized. In the former case, you must
229 /// Gets the capacity of the allocation.
233 pub fn capacity(&self) -> usize { in capacity() method
256 /// additional` elements. If it doesn't already have enough capacity, will
261 /// If `len` exceeds `self.capacity()`, this may fail to actually allocate
269 /// Panics if the new capacity exceeds `isize::MAX` bytes.
277 // Callers expect this function to be very cheap when there is already sufficient capacity. in reserve()
296 /// oft-instantiated `Vec::push()`, which does its own capacity check.
324 /// If `len` exceeds `self.capacity()`, this may fail to actually allocate
330 /// Panics if the new capacity exceeds `isize::MAX` bytes.
349 /// Shrinks the buffer down to the specified capacity. If the given amount
354 /// Panics if the given amount is *larger* than the current capacity.
366 /// Returns if the buffer needs to grow to fulfill the needed extra capacity.
369 additional > self.capacity().wrapping_sub(len) in needs_to_grow()
374 // the size requested. If that ever changes, the capacity here should in set_ptr_and_cap()
392 // Since we return a capacity of `usize::MAX` when `elem_size` is in grow_amortized()
418 // Since we return a capacity of `usize::MAX` when the type size is in grow_exact()
434 assert!(cap <= self.capacity(), "Tried to shrink to a larger capacity"); in shrink()
440 // overflowed earlier when capacity was larger. in shrink()
521 // One central function responsible for reporting capacity overflows. This'll
526 panic!("capacity overflow"); in capacity_overflow()