Vec with 'typed index'

Suppose we have:

pub struct Idx<V> {
    pub m_idx: usize,
    _t: PhantomData<V>,}

Now, suppose we have a

pub struct TypedVec<K, V> {
  data: Vec<V>,
  _t: PhantomData<K>,

and TypedVec<K, V> behaves just like a Vec<V> except that instead of indexing with usize, it indexes with Idx<K>.

This basically involves impling lots of functions on TypedVec<K, V>. Is there an existing crate that solves this ?

index_vec does this.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.