Rocket icon indicating copy to clipboard operation
Rocket copied to clipboard

`DoubleEndedIterator` implementation for `Segments`

Open rushiiMachine opened this issue 2 years ago • 3 comments

Existing Functionality

Currently there is only a forward iterator for Segments even though it is backed by a known size slice.

https://github.com/SergioBenitez/Rocket/blob/f1f533c1e5b0df5b44877d7cca39fb0f596a21b6/core/http/src/uri/segments.rs#L279-L295

Suggested Changes

Add a DoubleEndedIterator implementation to Segments to allow for iterating path segments in reverse for example, if be necessary.

Alternatives Considered

Collecting into a Vec and iterating in reverse is inefficient and for-i is just ugly and doesn't give clean flexibility.

rushiiMachine avatar May 05 '23 23:05 rushiiMachine

I'm not opposed to this, but the implementation would require great care. The inherent methods on Segments all assume that the iterator only moves forward, so something would need to be done about this.

SergioBenitez avatar May 06 '23 01:05 SergioBenitez

Can I work on it?

GentBinaku avatar Jan 09 '24 09:01 GentBinaku

Yes, please feel free!

SergioBenitez avatar Jan 09 '24 17:01 SergioBenitez