Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DoubleEndedIterator implementation for Segments #2535

Open
rushiiMachine opened this issue May 5, 2023 · 3 comments
Open

DoubleEndedIterator implementation for Segments #2535

rushiiMachine opened this issue May 5, 2023 · 3 comments
Labels
accepted An accepted request or suggestion suggestion A suggestion to change functionality

Comments

@rushiiMachine
Copy link

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 rushiiMachine added the suggestion A suggestion to change functionality label May 5, 2023
@SergioBenitez
Copy link
Member

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 SergioBenitez added accepted An accepted request or suggestion suggestion A suggestion to change functionality and removed suggestion A suggestion to change functionality labels May 6, 2023
@GentBinaku
Copy link

Can I work on it?

@SergioBenitez
Copy link
Member

Yes, please feel free!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted An accepted request or suggestion suggestion A suggestion to change functionality
Projects
None yet
Development

No branches or pull requests

3 participants