提交 040f1c06 编写于 作者: A Alex Crichton

Allow trailing commas in format!

This is more consistent with other parts of the language and it also makes it
easier to use in situations where format string is massive.
上级 0efc4822
......@@ -76,6 +76,7 @@ fn parse_args(&mut self, sp: Span,
self.ecx.span_err(sp, "expected token: `,`");
return (extra, None);
}
if *p.token == token::EOF { break } // accept trailing commas
if named || (token::is_ident(p.token) &&
p.look_ahead(1, |t| *t == token::EQ)) {
named = true;
......
......@@ -243,6 +243,10 @@ pub fn main() {
}
test_format_args();
// test that trailing commas are acceptable
format!("{}", "test",);
format!("{foo}", foo="test",);
}
// Basic test to make sure that we can invoke the `write!` macro with an
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册