Open Boscop opened 4 years ago
I had to switch over to using a Vec
because I couldn't efficiently insert multiple items into a VecDeque
. Having a splice method would've been really useful. If I can find some time these days, I might be able to work on a PR.
@rustbot claim
@tomkarw Thanks for working on this. Btw, what's the current status? :)
Sorry for the late response, apparently I don't get GitHub notification via email.
TBH, I thought it will be easier. The unsafe
code needed kinda scared me, and I got a job 4 days after claiming this.
I'll try to revisit it now, but will probably look for a mentor/guidance.
And what about a .prepend()
to mirror .append()
?
Hi, I just found out I'm encountering a case where prepend()
and/or extend_front()
methods on VecDeque
could be really useful.
I'm doing the work by iterating over other vector and push_front
repeatedly, but that feels not idiomatic and I guess not optimal at all.
If no one is available for this I might take a look at some point.
+1 for implementing this. Repeatedly calling push_front
has a significant performance impact for my use-case, so I ended-up hacking something together on top of a Vec
.
VecDeque
should supportsplice
for convenience. (SliceDeque
supports it, but it doesn't build on wasm and seems kind of abandoned (several unmerged PRs with no updates).)VecDeque
should also supportextend_front
(like repeatedpush_front
from an iterator. Compared to callingq.splice(..0, iter)
, the elements added withq.extend_front(iter)
would be in reverse order).