diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2021-12-21 22:17:17 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2021-12-21 23:13:45 +0100 |
| commit | 0d33f6dfa94c5e07b7ebcd882ddee0377f2c61c9 (patch) | |
| tree | bae739f41c453f6012fca0d5374d768603ed70c9 | |
| parent | 60f3bd78eeac87ad474916d36d29ed7e5084b25b (diff) | |
| download | rust-0d33f6dfa94c5e07b7ebcd882ddee0377f2c61c9.tar.gz rust-0d33f6dfa94c5e07b7ebcd882ddee0377f2c61c9.zip | |
Move pattern matching outside of the loop
| -rw-r--r-- | src/librustdoc/html/sources.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index ba70ed8622a..962a954ff74 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -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) } } } |
