Skip to content

use enumerate in place of 'for ti in range(i, tokens.len()) ...' #9030

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 4 additions & 4 deletions src/libextra/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,11 @@ impl Pattern {
&& is_sep(prev_char.unwrap_or_default('/')))
};

for ti in range(i, self.tokens.len()) {
match self.tokens[ti] {
for (ti, token) in self.tokens.slice_from(i).iter().enumerate() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean that ti_new == ti_old - i (i.e. it's a different number)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Updated the place where ti is used.

match *token {
AnySequence => {
loop {
match self.matches_from(prev_char, file, ti + 1, options) {
match self.matches_from(prev_char, file, i + ti + 1, options) {
SubPatternDoesntMatch => (), // keep trying
m => return m,
}
Expand All @@ -331,7 +331,7 @@ impl Pattern {
}

let (c, next) = file.slice_shift_char();
let matches = match self.tokens[ti] {
let matches = match *token {
AnyChar => {
!require_literal(c)
}
Expand Down