Open
Description
Hi 👋
I maintain a crate that abstracts over growable vectors such that they would be appropriate for implementing a Ruby Array
. This crate had backends for Vec
and SmallVec
. Yesterday I added a backend for TinyVec
.
PR is here: artichoke/artichoke#1094.
I based the TinyVec
backend on the existing backend for SmallVec
. Apart from adding a boatload of T: Default
bounds, the change was actually really small -- artichoke/artichoke@1935c05.
I appreciated the increased API compatibility with Vec
compared to SmallVec
, in particular a splice
method, which let me simplify several methods.
There were two things I was missing:
- There is no equivalent of
vec!
orSmallVec::from_elem
with a non-constant length. I had to useiter::repeat
like this:Self(iter::repeat(default).take(len).collect())
- There is no
From<Vec<T>>
impl, which forces one to go throughvec::IntoIter
even if theTinyVec
would be spilled with thisVec
.