pub trait VecLike:
Sized
+ From<Vec<Self::Type>>
+ Clone {
type Type: Copy + Default + Display + PartialEq;
Show 22 methods
// Required methods
fn with_capacity(c: usize) -> Self;
fn get(&self, i: usize) -> Self::Type;
fn set(&mut self, i: usize, val: Self::Type);
fn len(&self) -> usize;
fn push(&mut self, val: Self::Type);
fn pop(&mut self) -> Option<Self::Type>;
fn iter_values(&self) -> impl Iterator<Item = Self::Type>;
fn clear(&mut self);
fn resize(&mut self, new_len: usize, value: Self::Type);
fn reserve(&mut self, additional: usize);
// Provided methods
fn new() -> Self { ... }
fn get_checked(&self, i: usize) -> Result<Self::Type, CompVecError> { ... }
fn set_checked(
&mut self,
i: usize,
val: Self::Type,
) -> Result<(), CompVecError> { ... }
fn is_empty(&self) -> bool { ... }
fn append(&mut self, other: &mut Self) { ... }
fn insert(&mut self, index: usize, element: Self::Type) { ... }
fn remove(&mut self, index: usize) -> Self::Type { ... }
fn truncate(&mut self, len: usize) { ... }
fn extend_from_slice(&mut self, other: &[Self::Type]) { ... }
fn dedup(&mut self) { ... }
fn swap_remove(&mut self, index: usize) -> Self::Type { ... }
fn split_off(&mut self, at: usize) -> Self { ... }
}Expand description
Defines functionality for an object, which behaves almost like a Vec.
Required Associated Types§
Required Methods§
Sourcefn with_capacity(c: usize) -> Self
fn with_capacity(c: usize) -> Self
Creates a vector like object with capacity.
Sourcefn iter_values(&self) -> impl Iterator<Item = Self::Type>
fn iter_values(&self) -> impl Iterator<Item = Self::Type>
Returns an iterator over all values.
Provided Methods§
Sourcefn get_checked(&self, i: usize) -> Result<Self::Type, CompVecError>
fn get_checked(&self, i: usize) -> Result<Self::Type, CompVecError>
Returns entry at position i as value with bounds check beforehand.
Sourcefn set_checked(&mut self, i: usize, val: Self::Type) -> Result<(), CompVecError>
fn set_checked(&mut self, i: usize, val: Self::Type) -> Result<(), CompVecError>
Sets entry at position i with value val with bounds check beforehand.
Sourcefn insert(&mut self, index: usize, element: Self::Type)
fn insert(&mut self, index: usize, element: Self::Type)
Inserts an element at index. This operation may be inefficient, since the vector needs to be restructured.
Sourcefn remove(&mut self, index: usize) -> Self::Type
fn remove(&mut self, index: usize) -> Self::Type
Removes an element at index. This operation may be inefficient, since the vector needs to be restructured.
Sourcefn extend_from_slice(&mut self, other: &[Self::Type])
fn extend_from_slice(&mut self, other: &[Self::Type])
Appends all elements from the slice.
Sourcefn swap_remove(&mut self, index: usize) -> Self::Type
fn swap_remove(&mut self, index: usize) -> Self::Type
Swaps the last element with index and resizes vec. Returns the removed element at index.
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.
Implementations on Foreign Types§
Source§impl<T: Copy + Default + Display + PartialEq> VecLike for Vec<T>
Implement VecLike for Vec in the std-lib.
impl<T: Copy + Default + Display + PartialEq> VecLike for Vec<T>
Implement VecLike for Vec in the std-lib.