Skip to content

Commit

Permalink
Move pattern matching outside of the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Dec 21, 2021
1 parent 60f3bd7 commit 0d33f6d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/librustdoc/html/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,15 @@ crate fn print_src(
tmp /= 10;
}
line_numbers.write_str("<pre class=\"line-numbers\">");
for i in 1..=lines {
match source_context {
SourceContext::Standalone => {
writeln!(line_numbers, "<span id=\"{0}\">{0:1$}</span>", i, cols)
match source_context {
SourceContext::Standalone => {
for line in 1..=lines {
writeln!(line_numbers, "<span id=\"{0}\">{0:1$}</span>", line, cols)
}
SourceContext::Embedded { offset } => {
writeln!(line_numbers, "<span>{0:1$}</span>", i + offset, cols)
}
SourceContext::Embedded { offset } => {
for line in 1..=lines {
writeln!(line_numbers, "<span>{0:1$}</span>", line + offset, cols)
}
}
}
Expand Down

0 comments on commit 0d33f6d

Please sign in to comment.