You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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! or SmallVec::from_elem with a non-constant length. I had to use iter::repeat like this:
Self(iter::repeat(default).take(len).collect())
There is no From<Vec<T>> impl, which forces one to go through vec::IntoIter even if the TinyVec would be spilled with this Vec.
The text was updated successfully, but these errors were encountered:
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 forVec
andSmallVec
. Yesterday I added a backend forTinyVec
.PR is here: artichoke/artichoke#1094.
I based the
TinyVec
backend on the existing backend forSmallVec
. Apart from adding a boatload ofT: Default
bounds, the change was actually really small -- artichoke/artichoke@1935c05.I appreciated the increased API compatibility with
Vec
compared toSmallVec
, in particular asplice
method, which let me simplify several methods.There were two things I was missing:
vec!
orSmallVec::from_elem
with a non-constant length. I had to useiter::repeat
like this:From<Vec<T>>
impl, which forces one to go throughvec::IntoIter
even if theTinyVec
would be spilled with thisVec
.The text was updated successfully, but these errors were encountered: