提交 489296d8 编写于 作者: B bors

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`
......@@ -280,13 +280,15 @@ fn emit_source(
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)
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册