Struct Palette

Source
pub struct Palette<T> { /* private fields */ }
Expand description

A palette is a vector with limited capacity that allows searching indices of elements.

Implementations§

Source§

impl<T> Palette<T>
where T: Clone + Copy + Eq,

Source

pub fn new(capacity: usize) -> Self

Create a new empty palette with the specified capacity.

Source

pub fn with_defaults<I>(defaults: I, capacity: usize) -> Self
where I: IntoIterator<Item = T>,

Create a new palette of the specified capacity and fill it with the given iterator. At most capacity elements are took from the iterator.

Source

pub fn with_default(default: T, capacity: usize) -> Self

Create a new palette with a default element into it and with the specified capacity.

Source

pub fn from_raw(items: Vec<T>, capacity: usize) -> Self

Source

pub fn capacity(&self) -> usize

Source

pub fn len(&self) -> usize

Source

pub fn clear(&mut self)

Source

pub fn ensure_index(&mut self, target_item: T) -> Option<usize>

Source

pub fn insert_index(&mut self, target_item: T) -> Option<usize>

Source

pub fn search_index(&self, target_item: T) -> Option<usize>

Source

pub fn get_item(&self, index: usize) -> Option<T>

Source

pub fn iter(&self) -> impl Iterator<Item = T> + '_

Auto Trait Implementations§

§

impl<T> Freeze for Palette<T>

§

impl<T> RefUnwindSafe for Palette<T>
where T: RefUnwindSafe,

§

impl<T> Send for Palette<T>
where T: Send,

§

impl<T> Sync for Palette<T>
where T: Sync,

§

impl<T> Unpin for Palette<T>
where T: Unpin,

§

impl<T> UnwindSafe for Palette<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Component for T
where T: Send + Sync + 'static,