Skip to content

Commit

Permalink
Optimize Iterator::nth for the Enum* iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed Feb 25, 2020
1 parent c5a6559 commit c9a653b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,11 @@ impl<'key> Iterator for EnumKeys<'key> {
e @ None => e,
}
}

fn nth(&mut self, n: usize) -> Option<Self::Item> {
self.index += n as DWORD;
self.next()
}
}

/// Iterator over values
Expand All @@ -1051,6 +1056,11 @@ impl<'key> Iterator for EnumValues<'key> {
e @ None => e,
}
}

fn nth(&mut self, n: usize) -> Option<Self::Item> {
self.index += n as DWORD;
self.next()
}
}

fn to_utf16<P: AsRef<OsStr>>(s: P) -> Vec<u16> {
Expand Down

0 comments on commit c9a653b

Please sign in to comment.