dtolnay / syn

Parser for Rust source code
Apache License 2.0
2.79k stars 306 forks source link

Create braces around closure body during printing if needed #1658

Closed dtolnay closed 3 months ago

dtolnay commented 3 months ago

If a closure has an omitted return type, any kind of expression is allowed in the closure body: || 1 + 1. But if there is a return type, only a block expression is allowed: || -> i32 { 1 + 1 }. Without braces || -> i32 1 + 1 is not legal syntax.