@@ -806,7 +806,9 @@ path_glob : ident [ "::" path_glob ] ?
806
806
807
807
A _ use declaration_ creates one or more local name bindings synonymous
808
808
with some other [ path] ( #paths ) .
809
- Usually a ` use ` declaration is used to shorten the path required to refer to a module item.
809
+ Usually a ` use ` declaration is used to shorten the path required to refer to a
810
+ module item. These declarations may appear at the top of [ modules] ( #modules ) and
811
+ [ blocks] ( #blocks ) .
810
812
811
813
* Note* : Unlike in many languages,
812
814
` use ` declarations in Rust do * not* declare linkage dependency with external crates.
@@ -2318,14 +2320,24 @@ let base = Point3d {x: 1, y: 2, z: 3};
2318
2320
Point3d {y: 0, z: 10, .. base};
2319
2321
~~~~
2320
2322
2321
- ### Record expressions
2323
+ ### Block expressions
2322
2324
2323
2325
~~~~ {.ebnf .gram}
2324
- rec_expr : '{' ident ':' expr
2325
- [ ',' ident ':' expr ] *
2326
- [ ".." expr ] '}'
2326
+ block_expr : '{' [ view_item ] *
2327
+ [ stmt ';' | item ] *
2328
+ [ expr ] '}'
2327
2329
~~~~
2328
2330
2331
+ A _ block expression_ is similar to a module in terms of the declarations that
2332
+ are possible. Each block conceptually introduces a new namespace scope. View
2333
+ items can bring new names into scopes and declared items are in scope for only
2334
+ the block itself.
2335
+
2336
+ A block will execute each statement sequentially, and then execute the
2337
+ expression (if given). If the final expression is omitted, the type and return
2338
+ value of the block are ` () ` , but if it is provided, the type and return value
2339
+ of the block are that of the expression itself.
2340
+
2329
2341
### Method-call expressions
2330
2342
2331
2343
~~~~ {.ebnf .gram}
0 commit comments