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

Iterator direction #2

Closed
valmirjunior0088 opened this issue Jan 8, 2020 · 2 comments · Fixed by #3
Closed

Iterator direction #2

valmirjunior0088 opened this issue Jan 8, 2020 · 2 comments · Fixed by #3

Comments

@valmirjunior0088
Copy link
Contributor

Is there some specific reason why you .rev() each half of the iterator separately?

Also, is there a way to get the other direction (oldest to newest) without having to .rev() the iterator each time it is used? Perhaps you could add an iterator like the following:

let (first_half, second_half) = self.data.split_at(self.insertion_index);
second_half.iter().chain(first_half.iter())
@YaLTeR
Copy link
Owner

YaLTeR commented Jan 8, 2020

Is there some specific reason why you .rev() each half of the iterator separately?

I suppose that part can be rewritten as b.iter().chain(a.iter()).rev(), yeah. Unfortunately, that would be a breaking change as I chose to use an explicitly specified type alias for the iterator type rather than a newtype (for no particular reason), so I think I'd rather avoid chaging it unless there's a good justification.

Also, is there a way to get the other direction (oldest to newest) without having to .rev() the iterator each time it is used? Perhaps you could add an iterator like the following:

let (first_half, second_half) = self.data.split_at(self.insertion_index);
second_half.iter().chain(first_half.iter())

Sure, that should work. The usual method could even be implemented in terms of this one, then, assuming a breaking change was made. But since I'd like no breaking changes, this could just be a separate method. Could you send a PR?

@valmirjunior0088
Copy link
Contributor Author

Since you don't want a breaking change, what would you suggest the new function name be? I'm having a hard time thinking of one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants