Skip to content

Commit 489296d

Browse files
committed
Auto merge of #92177 - GuillaumeGomez:pattern-matching-outside-loop, r=camelid
Move pattern matching outside of the loop Not sure if worth it but it's been bugging me for a while now. r? `@camelid`
2 parents c1d301b + 0d33f6d commit 489296d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/librustdoc/html/sources.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,15 @@ crate fn print_src(
280280
tmp /= 10;
281281
}
282282
line_numbers.write_str("<pre class=\"line-numbers\">");
283-
for i in 1..=lines {
284-
match source_context {
285-
SourceContext::Standalone => {
286-
writeln!(line_numbers, "<span id=\"{0}\">{0:1$}</span>", i, cols)
283+
match source_context {
284+
SourceContext::Standalone => {
285+
for line in 1..=lines {
286+
writeln!(line_numbers, "<span id=\"{0}\">{0:1$}</span>", line, cols)
287287
}
288-
SourceContext::Embedded { offset } => {
289-
writeln!(line_numbers, "<span>{0:1$}</span>", i + offset, cols)
288+
}
289+
SourceContext::Embedded { offset } => {
290+
for line in 1..=lines {
291+
writeln!(line_numbers, "<span>{0:1$}</span>", line + offset, cols)
290292
}
291293
}
292294
}

0 commit comments

Comments
 (0)