pub trait Vector<T>:
Deref<Target = [T]>
+ DerefMut
+ VectorView<T> {
Show 17 methods
// Required methods
fn capacity(&self) -> usize;
fn len(&self) -> usize;
// Provided methods
fn as_mut_slice(&mut self) -> &mut [T] { ... }
fn as_slice(&self) -> &[T] { ... }
fn clear(&mut self) { ... }
fn extend_from_slice(
&mut self,
other: &[T],
) -> Result<(), VectorModificationError>
where T: Clone { ... }
unsafe fn extend_from_slice_unchecked(&mut self, other: &[T])
where T: Clone { ... }
fn insert(
&mut self,
index: usize,
element: T,
) -> Result<(), VectorModificationError> { ... }
fn is_empty(&self) -> bool { ... }
fn is_full(&self) -> bool { ... }
fn pop(&mut self) -> Option<T> { ... }
fn push(&mut self, value: T) -> Result<(), VectorModificationError> { ... }
unsafe fn push_unchecked(&mut self, value: T) { ... }
fn remove(&mut self, index: usize) -> Option<T> { ... }
fn resize(
&mut self,
new_len: usize,
value: T,
) -> Result<(), VectorModificationError>
where T: Clone { ... }
fn resize_with<F: FnMut() -> T>(
&mut self,
new_len: usize,
f: F,
) -> Result<(), VectorModificationError> { ... }
fn truncate(&mut self, new_len: usize) { ... }
}Expand description
Defines the interface of a vector.
Required Methods§
Provided Methods§
Sourcefn as_mut_slice(&mut self) -> &mut [T]
fn as_mut_slice(&mut self) -> &mut [T]
Returns a mutable slice to the contents of the vector
Sourcefn extend_from_slice(
&mut self,
other: &[T],
) -> Result<(), VectorModificationError>where
T: Clone,
fn extend_from_slice(
&mut self,
other: &[T],
) -> Result<(), VectorModificationError>where
T: Clone,
Append all elements from other via Clone.
Sourceunsafe fn extend_from_slice_unchecked(&mut self, other: &[T])where
T: Clone,
unsafe fn extend_from_slice_unchecked(&mut self, other: &[T])where
T: Clone,
Sourcefn insert(
&mut self,
index: usize,
element: T,
) -> Result<(), VectorModificationError>
fn insert( &mut self, index: usize, element: T, ) -> Result<(), VectorModificationError>
Inserts an element at the provided index and shifting all elements after the index to the right.
Sourcefn pop(&mut self) -> Option<T>
fn pop(&mut self) -> Option<T>
Removes the last element of the vector and returns it to the user. If the vector is empty
it returns None.
Sourcefn push(&mut self, value: T) -> Result<(), VectorModificationError>
fn push(&mut self, value: T) -> Result<(), VectorModificationError>
Adds an element at the end of the vector. If the vector is full and the element cannot be
added it returns VectorModificationError::InsertWouldExceedCapacity.
Sourceunsafe fn push_unchecked(&mut self, value: T)
unsafe fn push_unchecked(&mut self, value: T)
Sourcefn remove(&mut self, index: usize) -> Option<T>
fn remove(&mut self, index: usize) -> Option<T>
Removes the element at the provided index and returns it.
Sourcefn resize(
&mut self,
new_len: usize,
value: T,
) -> Result<(), VectorModificationError>where
T: Clone,
fn resize(
&mut self,
new_len: usize,
value: T,
) -> Result<(), VectorModificationError>where
T: Clone,
Fill the remaining space of the vector with value.
Sourcefn resize_with<F: FnMut() -> T>(
&mut self,
new_len: usize,
f: F,
) -> Result<(), VectorModificationError>
fn resize_with<F: FnMut() -> T>( &mut self, new_len: usize, f: F, ) -> Result<(), VectorModificationError>
Fill the remaining space of the vector with value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.