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

nth_back wasn't stablilized until 1.37 #85

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions strum_macros/src/macros/enum_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ pub fn enum_iter_inner(ast: &syn::DeriveInput) -> TokenStream {

impl #impl_generics DoubleEndedIterator for #iter_name #ty_generics #where_clause {
fn next_back(&mut self) -> Option<Self::Item> {
self.nth_back(0)
}

fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
let back_idx = self.back_idx + n + 1;
let back_idx = self.back_idx + 1;

if self.idx + back_idx > #variant_count {
// We went past the end of the iterator. Freeze back_idx at #variant_count
Expand Down