arrayvec
arrayvec copied to clipboard
Implement `Index` and `IndexMut` traits for `ArrayVec`
I didn't have time to add tests to it yet, but this should implement Index<I> and IndexMut<I> where I: SliceIndex<[T]>.
Fixes #190
Instead of this implementation (self.get[_mut](index).unwrap()) we could also use
self.deref().index[_mut](index)
Maybe that gives better error messages in some situations? I don't know...
Looks to be in the right direction, that's nice - I'll be a bit unreachable during the summer, but back in a bit
No problem.
I changed the implementation as described above because it indeed gives much better error messages on out of bounds errors, and added some tests.
So I changed the trait bounds as you suggested and just now added implementations to ArrayString analogous to those for ArrayVec.
I also removed the documentation I initially added to the Index/IndexMut implementation since the comment on panicing needn't be true for all instantiations of the generic parameter.