How to allow arbitrary expressions in format strings

format!("...{var}...") is syntactic sugar for format!("...{var}...", var=var). I don't think we should provide a syntactic sugar for format!("...{var}...", var=foo+bar.baz()); I don't think we should support nesting arbitrary expressions into the format string. Simple braced identifiers are easy to mentally parse without ambiguity; arbitrary expressions are not.

If we consider allowing arbitrary expressions, I think parentheses would be a good minimum requirement.

25 Likes