Trait IsIndexContainer

Source
pub trait IsIndexContainer: Clone + Default {
    // Required methods
    fn reserve(&mut self, n: usize);
    fn ensure_supported(&mut self, x: usize);
    fn len(&self) -> usize;
    fn get(&self, index: usize) -> usize;
    fn set(&mut self, index: usize, value: usize);
    fn push(&mut self, value: usize);
    fn iter(&self) -> IsIndexContainerIterator<'_, Self> ;

    // Provided methods
    fn with_capacity(n: usize) -> Self { ... }
    fn with_support_for(x: usize) -> Self { ... }
    fn with_capacity_and_support_for(n: usize, x: usize) -> Self { ... }
}
Expand description

IsIndexContainer trait for containers holding indices

Required Methods§

Source

fn reserve(&mut self, n: usize)

Should reserve space for n more elements

Source

fn ensure_supported(&mut self, x: usize)

Should ensure that given number can be supported

Source

fn len(&self) -> usize

Should return the number of elements

Source

fn get(&self, index: usize) -> usize

Should return the element at index

Source

fn set(&mut self, index: usize, value: usize)

Should overwrite the element at index with value

Source

fn push(&mut self, value: usize)

Should push value to the end of the container

Source

fn iter(&self) -> IsIndexContainerIterator<'_, Self>

Should return an iterator over the values

Provided Methods§

Source

fn with_capacity(n: usize) -> Self

Creates a new object with the given capacity

Source

fn with_support_for(x: usize) -> Self

Creates a new object that can support the given number

Source

fn with_capacity_and_support_for(n: usize, x: usize) -> Self

Creates a new object with the given capacity and support for the given number

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 IsIndexContainer for Vec<usize>

Source§

fn ensure_supported(&mut self, _x: usize)

Source§

fn reserve(&mut self, n: usize)

Source§

fn len(&self) -> usize

Source§

fn get(&self, index: usize) -> usize

Source§

fn set(&mut self, index: usize, value: usize)

Source§

fn push(&mut self, value: usize)

Source§

fn iter(&self) -> IsIndexContainerIterator<'_, Self>

Implementors§