Struct containers::collections::Vec [−][src]
pub struct Vec<T, A: Alloc = NullAllocator> { /* fields omitted */ }
Growable array
Methods
impl<T, A: Alloc> Vec<T, A>[src]
impl<T, A: Alloc> Vec<T, A>pub fn new_in(a: A) -> Vec<T, A>[src]
pub fn new_in(a: A) -> Vec<T, A>Make a new array.
pub fn with_capacity_in(a: A, cap: usize) -> Option<Vec<T, A>>[src]
pub fn with_capacity_in(a: A, cap: usize) -> Option<Vec<T, A>>Make a new array with enough room to hold at least cap elements.
Failures
Returns None if allocation fails.
pub unsafe fn set_length(&mut self, len: usize)[src]
pub unsafe fn set_length(&mut self, len: usize)pub fn capacity(&self) -> usize[src]
pub fn capacity(&self) -> usizeReturn number of elements array can hold before reallocation.
pub unsafe fn storage_mut(&mut self) -> &mut [T][src]
pub unsafe fn storage_mut(&mut self) -> &mut [T]pub fn reserve(&mut self, n_more: usize) -> bool[src]
pub fn reserve(&mut self, n_more: usize) -> boolMake 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.
pub fn relinquish(&mut self) -> bool[src]
pub fn relinquish(&mut self) -> boolRelinquish memory so capacity = length.
pub fn insert(&mut self, k: usize, x: T) -> Result<(), T>[src]
pub fn insert(&mut self, k: usize, x: T) -> Result<(), T>Insert element x at position k, shifting elements after k aftward one position to make room.
Failures
Returns Err(x) if allocation fails.
Panics
Panics if k is out of bounds.
pub fn delete(&mut self, k: usize) -> T[src]
pub fn delete(&mut self, k: usize) -> TDelete 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.
pub fn delete_swap_last(&mut self, k: usize) -> T[src]
pub fn delete_swap_last(&mut self, k: usize) -> TDelete element at position k and move the last element into the gap.
Panics
Panics if k is out of bounds.
pub fn push(&mut self, x: T) -> Result<(), T>[src]
pub fn push(&mut self, x: T) -> Result<(), T>pub fn pop(&mut self) -> Option<T>[src]
pub fn pop(&mut self) -> Option<T>Pop last element off end of array.
Return None if array empty.
pub fn append<B: Alloc>(&mut self, xs: Vec<T, B>) -> Result<(), Vec<T, B>>[src]
pub fn append<B: Alloc>(&mut self, xs: Vec<T, B>) -> Result<(), Vec<T, B>>Append xs to the array.
Failures
Returns Err(xs) if allocation fails, in which case both self and xs are unmodified.
pub fn append_slice(&mut self, xs: &[T]) -> bool where
T: Copy, [src]
pub fn append_slice(&mut self, xs: &[T]) -> bool where
T: Copy, Copy xs and append it to the array.
Failures
Returns false if allocation fails, in which case self is unmodified.
pub fn extend<Ts: IntoIterator<Item = T>>(
&mut self,
xs: Ts
) -> Result<(), Ts::IntoIter>[src]
pub fn extend<Ts: IntoIterator<Item = T>>(
&mut self,
xs: Ts
) -> Result<(), Ts::IntoIter>Add elements of xs to aft end of array.
Failures
Returns Err of remainder of xs if allocation fails.
pub fn from_iter_in<Ts: IntoIterator<Item = T>>(
a: A,
xs: Ts
) -> Result<Self, Ts::IntoIter>[src]
pub fn from_iter_in<Ts: IntoIterator<Item = T>>(
a: A,
xs: Ts
) -> Result<Self, Ts::IntoIter>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.
pub fn truncate(&mut self, len: usize)[src]
pub fn truncate(&mut self, len: usize)Shorten array to len and drop elements beyond.
pub fn from_raw(raw: RawVec<T, A>) -> Self[src]
pub fn from_raw(raw: RawVec<T, A>) -> Selfpub fn drain<R>(&mut self, r: R) -> Drain<T, A> where
Self: IndexMut<R, Output = [T]>, [src]
pub fn drain<R>(&mut self, r: R) -> Drain<T, A> where
Self: IndexMut<R, Output = [T]>, pub fn drain_filter<R, F>(
&mut self,
range: R,
filter: F
) -> DrainFilter<T, F, A> where
Self: IndexMut<R, Output = [T]>,
F: FnMut(usize, &mut T) -> bool, [src]
pub fn drain_filter<R, F>(
&mut self,
range: R,
filter: F
) -> DrainFilter<T, F, A> where
Self: IndexMut<R, Output = [T]>,
F: FnMut(usize, &mut T) -> bool, impl<T, A: Alloc + Default> Vec<T, A>[src]
impl<T, A: Alloc + Default> Vec<T, A>pub fn new() -> Self[src]
pub fn new() -> SelfMake a new array.
pub fn with_capacity(cap: usize) -> Option<Self>[src]
pub fn with_capacity(cap: usize) -> Option<Self>Make a new array with enough room to hold at least cap elements.
Failures
Returns None if allocation fails.
pub fn from_iter<Ts: IntoIterator<Item = T>>(
xs: Ts
) -> Result<Self, Ts::IntoIter>[src]
pub fn from_iter<Ts: IntoIterator<Item = T>>(
xs: Ts
) -> Result<Self, Ts::IntoIter>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.
impl<T, A: Alloc + TryClone> Vec<T, A>[src]
impl<T, A: Alloc + TryClone> Vec<T, A>Trait Implementations
impl<T: TryClone, A: Alloc + TryClone> TryClone for Vec<T, A>[src]
impl<T: TryClone, A: Alloc + TryClone> TryClone for Vec<T, A>type Error = Option<Either<A::Error, T::Error>>
fn try_clone(&self) -> Result<Self, Self::Error>[src]
fn try_clone(&self) -> Result<Self, Self::Error>fn try_clone_from(&mut self, other: &Self) -> Result<(), Self::Error>[src]
fn try_clone_from(&mut self, other: &Self) -> Result<(), Self::Error>impl<T, A: Alloc> Drop for Vec<T, A>[src]
impl<T, A: Alloc> Drop for Vec<T, A>impl<T, A: Alloc + Default> Default for Vec<T, A>[src]
impl<T, A: Alloc + Default> Default for Vec<T, A>impl<T: PartialEq, A: Alloc> PartialEq for Vec<T, A>[src]
impl<T: PartialEq, A: Alloc> PartialEq for Vec<T, A>fn eq(&self, other: &Self) -> bool[src]
fn eq(&self, other: &Self) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl<T: PartialOrd, A: Alloc> PartialOrd for Vec<T, A>[src]
impl<T: PartialOrd, A: Alloc> PartialOrd for Vec<T, A>fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
fn lt(&self, other: &Rhs) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0[src]
fn le(&self, other: &Rhs) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
fn gt(&self, other: &Rhs) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
fn ge(&self, other: &Rhs) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl<T: Eq, A: Alloc> Eq for Vec<T, A>[src]
impl<T: Eq, A: Alloc> Eq for Vec<T, A>impl<T: Ord, A: Alloc> Ord for Vec<T, A>[src]
impl<T: Ord, A: Alloc> Ord for Vec<T, A>fn cmp(&self, other: &Self) -> Ordering[src]
fn cmp(&self, other: &Self) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl<T, A: Alloc> Index<usize> for Vec<T, A>[src]
impl<T, A: Alloc> Index<usize> for Vec<T, A>type Output = <[T] as Index<usize>>::Output
The returned type after indexing.
fn index(&self, k: usize) -> &Self::Output[src]
fn index(&self, k: usize) -> &Self::OutputPerforms the indexing (container[index]) operation.
impl<T, A: Alloc> IndexMut<usize> for Vec<T, A>[src]
impl<T, A: Alloc> IndexMut<usize> for Vec<T, A>fn index_mut(&mut self, k: usize) -> &mut Self::Output[src]
fn index_mut(&mut self, k: usize) -> &mut Self::OutputPerforms the mutable indexing (container[index]) operation.
impl<T, A: Alloc> Index<Range<usize>> for Vec<T, A>[src]
impl<T, A: Alloc> Index<Range<usize>> for Vec<T, A>type Output = <[T] as Index<Range<usize>>>::Output
The returned type after indexing.
fn index(&self, k: Range<usize>) -> &Self::Output[src]
fn index(&self, k: Range<usize>) -> &Self::OutputPerforms the indexing (container[index]) operation.
impl<T, A: Alloc> IndexMut<Range<usize>> for Vec<T, A>[src]
impl<T, A: Alloc> IndexMut<Range<usize>> for Vec<T, A>fn index_mut(&mut self, k: Range<usize>) -> &mut Self::Output[src]
fn index_mut(&mut self, k: Range<usize>) -> &mut Self::OutputPerforms the mutable indexing (container[index]) operation.
impl<T, A: Alloc> Index<RangeTo<usize>> for Vec<T, A>[src]
impl<T, A: Alloc> Index<RangeTo<usize>> for Vec<T, A>type Output = <[T] as Index<RangeTo<usize>>>::Output
The returned type after indexing.
fn index(&self, k: RangeTo<usize>) -> &Self::Output[src]
fn index(&self, k: RangeTo<usize>) -> &Self::OutputPerforms the indexing (container[index]) operation.
impl<T, A: Alloc> IndexMut<RangeTo<usize>> for Vec<T, A>[src]
impl<T, A: Alloc> IndexMut<RangeTo<usize>> for Vec<T, A>fn index_mut(&mut self, k: RangeTo<usize>) -> &mut Self::Output[src]
fn index_mut(&mut self, k: RangeTo<usize>) -> &mut Self::OutputPerforms the mutable indexing (container[index]) operation.
impl<T, A: Alloc> Index<RangeFrom<usize>> for Vec<T, A>[src]
impl<T, A: Alloc> Index<RangeFrom<usize>> for Vec<T, A>type Output = <[T] as Index<RangeFrom<usize>>>::Output
The returned type after indexing.
fn index(&self, k: RangeFrom<usize>) -> &Self::Output[src]
fn index(&self, k: RangeFrom<usize>) -> &Self::OutputPerforms the indexing (container[index]) operation.
impl<T, A: Alloc> IndexMut<RangeFrom<usize>> for Vec<T, A>[src]
impl<T, A: Alloc> IndexMut<RangeFrom<usize>> for Vec<T, A>fn index_mut(&mut self, k: RangeFrom<usize>) -> &mut Self::Output[src]
fn index_mut(&mut self, k: RangeFrom<usize>) -> &mut Self::OutputPerforms the mutable indexing (container[index]) operation.
impl<T, A: Alloc> Index<RangeFull> for Vec<T, A>[src]
impl<T, A: Alloc> Index<RangeFull> for Vec<T, A>type Output = <[T] as Index<RangeFull>>::Output
The returned type after indexing.
fn index(&self, k: RangeFull) -> &Self::Output[src]
fn index(&self, k: RangeFull) -> &Self::OutputPerforms the indexing (container[index]) operation.
impl<T, A: Alloc> IndexMut<RangeFull> for Vec<T, A>[src]
impl<T, A: Alloc> IndexMut<RangeFull> for Vec<T, A>fn index_mut(&mut self, k: RangeFull) -> &mut Self::Output[src]
fn index_mut(&mut self, k: RangeFull) -> &mut Self::OutputPerforms the mutable indexing (container[index]) operation.
impl<T, A: Alloc> Borrow<[T]> for Vec<T, A>[src]
impl<T, A: Alloc> Borrow<[T]> for Vec<T, A>impl<T, A: Alloc> BorrowMut<[T]> for Vec<T, A>[src]
impl<T, A: Alloc> BorrowMut<[T]> for Vec<T, A>fn borrow_mut(&mut self) -> &mut [T][src]
fn borrow_mut(&mut self) -> &mut [T]Mutably borrows from an owned value. Read more
impl<T, A: Alloc> Deref for Vec<T, A>[src]
impl<T, A: Alloc> Deref for Vec<T, A>type Target = [T]
The resulting type after dereferencing.
fn deref(&self) -> &[T][src]
fn deref(&self) -> &[T]Dereferences the value.
impl<T, A: Alloc> DerefMut for Vec<T, A>[src]
impl<T, A: Alloc> DerefMut for Vec<T, A>impl<T: Hash, A: Alloc> Hash for Vec<T, A>[src]
impl<T: Hash, A: Alloc> Hash for Vec<T, A>fn hash<H: Hasher>(&self, h: &mut H)[src]
fn hash<H: Hasher>(&self, h: &mut H)Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl<T: Debug, A: Alloc> Debug for Vec<T, A>[src]
impl<T: Debug, A: Alloc> Debug for Vec<T, A>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<T, A: Alloc> IntoIterator for Vec<T, A>[src]
impl<T, A: Alloc> IntoIterator for Vec<T, A>type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIter<T, A>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IntoIter<T, A>[src]
fn into_iter(self) -> IntoIter<T, A>Creates an iterator from a value. Read more
impl<'a, T, A: Alloc> IntoIterator for &'a Vec<T, A>[src]
impl<'a, T, A: Alloc> IntoIterator for &'a Vec<T, A>type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
ⓘImportant traits for Iter<'a, T>fn into_iter(self) -> Iter<'a, T>[src]
fn into_iter(self) -> Iter<'a, T>Creates an iterator from a value. Read more
impl<'a, T, A: Alloc> IntoIterator for &'a mut Vec<T, A>[src]
impl<'a, T, A: Alloc> IntoIterator for &'a mut Vec<T, A>