1
0
mirror of https://github.com/danog/strum.git synced 2024-11-30 04:28:59 +01:00

nth_back wasn't stablilized until 1.37 (#85)

This commit is contained in:
Peter Glotfelty 2020-02-10 15:58:11 -08:00 committed by GitHub
parent 043b60f6d8
commit de17e1c7a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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