Closed dtolnay closed 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.
|| 1 + 1
|| -> i32 { 1 + 1 }
|| -> i32 1 + 1
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.