Pseudo-RFC: Cursors (Reversible Iterators)

I really like the idea of a DoubleEndedCursor (or even DoubleEndedZipper?).

My personal use-case stems from trying to write an in-place partitioning algorithm for slices. My first attempt used indices and entirely safe code, but the indexing and bounds checking made it a fair bit slower than the C++ iterator-based implementation.

For my second attempt I tried to use a (mutable) DoubleEndedIterator, but it was a non-starter because for this algorithm you have to be able to access the value you’re currently at without going to the next value. So in the end I wrote it with unsafe code and raw pointers (and its performance is pretty comparable to the C++ version!).

Being able to write a version of that which is both safe and efficient would be awesome.