One reason to have them separate is so that the pop
s only need to update one field, not both. That's also why the slice iterators are two pointers instead of just pointer + length the way normal slices are.
I wouldn't couple those; supporting cap == 0
should be completely doable, just would need a good test suite and careful analysis to ensure every corner is covered.
What I really wish we had, though, was a representative set of VecDeque
benchmarks. Because it's really not obvious to me that the power-of-two restriction is even all that important -- sure, it make modular indexing faster, but we don't actually do full modular indexing. It's only ever - if i >= cap { cap } else { 0 }
.
And opening up "yes, you can always convert a Vec
into a VecDeque
without it needing to allocate" would be a way bigger ecosystem boost, in my estimation, than saving the occasional cmov.