Skip to main content

VecLike

Trait VecLike 

Source
pub trait VecLike<T>: BufferData<T> + Extend<T> {
    // Required methods
    fn capacity(&self) -> usize;
    fn push(&mut self, value: T);
    fn clear(&mut self);
    fn resize(&mut self, new_len: usize, value: T)
       where T: Clone;
    fn extend_from_slice(&mut self, other: &[T])
       where T: Clone;
    fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>];
    unsafe fn set_len(&mut self, new_len: usize);
}
Expand description

A growable, Vec-like buffer.

Abstracts the buffer surface the prover uses: BufferData plus a subset of Vec’s API. Implemented by Vec<T> and PoolVec, with methods added as callers need them. It is not meant to mirror all of Vec.

Required Methods§

Source

fn capacity(&self) -> usize

Returns the number of elements the buffer can hold without reallocating.

Source

fn push(&mut self, value: T)

Appends an element to the back of the buffer.

Source

fn clear(&mut self)

Clears the buffer, removing all elements while retaining its capacity.

Source

fn resize(&mut self, new_len: usize, value: T)
where T: Clone,

Resizes the buffer to new_len, filling any new slots with value.

Source

fn extend_from_slice(&mut self, other: &[T])
where T: Clone,

Appends all elements of other to the back of the buffer.

Source

fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>]

Returns the spare capacity of the buffer as a slice of MaybeUninit<T>.

Source

unsafe fn set_len(&mut self, new_len: usize)

Forces the length of the buffer to new_len.

§Safety

Same contract as Vec::set_len: new_len must be at most capacity and the elements in 0..new_len must be initialized.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> VecLike<T> for Vec<T>

Source§

fn capacity(&self) -> usize

Source§

fn push(&mut self, value: T)

Source§

fn clear(&mut self)

Source§

fn resize(&mut self, new_len: usize, value: T)
where T: Clone,

Source§

fn extend_from_slice(&mut self, other: &[T])
where T: Clone,

Source§

fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>]

Source§

unsafe fn set_len(&mut self, new_len: usize)

Implementors§

Source§

impl<T> VecLike<T> for PoolVec<'_, T>