pub trait VecLike: IntoIterator<Item = Self::T> + Extend<Self::T> {
type T;
// Required methods
fn with_capacity(n: usize) -> Self
where Self: Sized;
fn push(&mut self, x: Self::T);
fn pop(&mut self) -> Option<Self::T>;
fn len(&self) -> usize;
fn as_slice(&self) -> &[Self::T];
// Provided methods
fn new() -> Self
where Self: Sized { ... }
fn map_elements<T2, E2>(self, f: impl FnMut(Self::T) -> T2) -> E2
where E2: VecLike<T = T2>,
Self: Sized { ... }
fn is_empty(&self) -> bool { ... }
}
Expand description
A trait for mutable growable vectors.
Required Associated Types§
Required Methods§
Sourcefn with_capacity(n: usize) -> Selfwhere
Self: Sized,
fn with_capacity(n: usize) -> Selfwhere
Self: Sized,
Create an instance of this container with at least n
elements allocated.
Provided Methods§
Sourcefn new() -> Selfwhere
Self: Sized,
fn new() -> Selfwhere
Self: Sized,
Create an instance of this container without allocating any memory.
Also see ConstDefault
for an orthogonal trait for const
instances.
Sourcefn map_elements<T2, E2>(self, f: impl FnMut(Self::T) -> T2) -> E2
fn map_elements<T2, E2>(self, f: impl FnMut(Self::T) -> T2) -> E2
Convert an instance of this vector into another type.
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.