Struct containers::collections::Vec [−][src]
pub struct Vec<T, A: Alloc = NullAllocator> { /* fields omitted */ }
Expand description
Growable array
Implementations
Make a new array with enough room to hold at least cap
elements.
Failures
Returns None
if allocation fails.
Make sure the array has enough room for at least n_more
more elements, reallocating if need be.
Failures
Returns false
if allocation fails, true
otherwise.
Relinquish memory so capacity = length.
Delete element at position k
and return it, shifting elements after k
forward one position to fill the gap.
Panics
Panics if k
is out of bounds.
Delete element at position k
and move the last element into the gap.
Panics
Panics if k
is out of bounds.
Pop last element off end of array.
Return None
if array empty.
Append xs
to the array.
Failures
Returns Err(xs)
if allocation fails, in which case both self
and xs
are unmodified.
Copy xs
and append it to the array.
Failures
Returns false
if allocation fails, in which case self
is unmodified.
Add elements of xs
to aft end of array.
Failures
Returns Err
of remainder of xs
if allocation fails.
Add elements of xs
to aft end of array.
Failures
Returns Err
of remainder of xs
if allocation fails, in which case some elements may have been added to xs
already.
Trait Implementations
Mutably borrows from an owned value. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl<T, A> RefUnwindSafe for Vec<T, A> where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> UnwindSafe for Vec<T, A> where
A: UnwindSafe,
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations
Returns a pointer meeting the size and alignment guarantees of
layout
. Read more
Deallocate the memory referenced by ptr
. Read more
Returns a pointer suitable for holding data described by
new_layout
, meeting its size and alignment guarantees. To
accomplish this, this may extend or shrink the allocation
referenced by ptr
to fit new_layout
. Read more
Behaves like alloc
, but also ensures that the contents
are set to zero before being returned. Read more
Behaves like alloc
, but also returns the whole size of
the returned block. For some layout
inputs, like arrays, this
may include extra storage usable for additional data. Read more
Behaves like realloc
, but also returns the whole size of
the returned block. For some layout
inputs, like arrays, this
may include extra storage usable for additional data. Read more
pub unsafe fn resize_in_place(
&mut self,
ptr: NonNull<u8>,
old_l: Layout,
new_size: usize
) -> Result<(), CannotReallocInPlace>
pub unsafe fn resize_in_place(
&mut self,
ptr: NonNull<u8>,
old_l: Layout,
new_size: usize
) -> Result<(), CannotReallocInPlace>
Attempts to resize the allocation referenced by ptr
to fit new_layout
. Read more
Returns bounds on the guaranteed usable size of a successful
allocation created with the specified layout
. Read more
Allocates a block suitable for holding an instance of T
. Read more
Deallocates a block suitable for holding an instance of T
. Read more
Allocates a block suitable for holding n
instances of T
. Read more
Reallocates a block previously suitable for holding n_old
instances of T
, returning a block suitable for holding
n_new
instances of T
. Read more
Mutably borrows from an owned value. Read more