UniqueVec

Struct UniqueVec 

Source
struct UniqueVec<T: Clone + Hash + Eq> {
    items: Vec<T>,
    index: HashMap<T, usize>,
}
Expand description

An array of objects with the following properties:

  • each item appears only once
  • efficient insertion and lookup of indexes of existing items
  • insertion order is maintained, indexes are stable across modification
  • can do .as_bytes() for items that are IntoBytes + Immutable

Fields§

§items: Vec<T>§index: HashMap<T, usize>

Implementations§

Source§

impl<T: Clone + Hash + Eq + IntoBytes + Immutable> UniqueVec<T>

Source

fn as_bytes(&self) -> &[u8]

Source§

impl<T: Clone + Hash + Eq> UniqueVec<T>

Source

fn new() -> Self

Source

fn get(&self, item: &T) -> Option<usize>

Source

fn ensure(&mut self, item: &T) -> usize

Source

fn get_by_index(&self, idx: usize) -> Option<&T>

Get an item by its index.

Trait Implementations§

Source§

impl<T: Clone + Hash + Eq + Debug> Debug for UniqueVec<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for UniqueVec<T>

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for UniqueVec<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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V