pub trait VecExt<T>: Sized {
// Required methods
fn with_capacity(capacity: usize, flags: Flags) -> Result<Self, AllocError>;
fn push(&mut self, v: T, flags: Flags) -> Result<(), AllocError>;
fn extend_from_slice(
&mut self,
other: &[T],
flags: Flags
) -> Result<(), AllocError>
where T: Clone;
fn reserve(
&mut self,
additional: usize,
flags: Flags
) -> Result<(), AllocError>;
}
Expand description
Extensions to Vec
.
Required Methods§
sourcefn with_capacity(capacity: usize, flags: Flags) -> Result<Self, AllocError>
fn with_capacity(capacity: usize, flags: Flags) -> Result<Self, AllocError>
sourcefn extend_from_slice(
&mut self,
other: &[T],
flags: Flags
) -> Result<(), AllocError>where
T: Clone,
fn extend_from_slice(
&mut self,
other: &[T],
flags: Flags
) -> Result<(), AllocError>where
T: Clone,
sourcefn reserve(&mut self, additional: usize, flags: Flags) -> Result<(), AllocError>
fn reserve(&mut self, additional: usize, flags: Flags) -> Result<(), AllocError>
Ensures that the capacity exceeds the length by at least additional
elements.
§Examples
let mut v = Vec::new();
v.push(1, GFP_KERNEL)?;
v.reserve(10, GFP_KERNEL)?;
let cap = v.capacity();
assert!(cap >= 10);
v.reserve(10, GFP_KERNEL)?;
let new_cap = v.capacity();
assert_eq!(new_cap, cap);
Object Safety§
This trait is not object safe.