about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-01-16 19:21:45 -0800
committerbors <bors@rust-lang.org>2014-01-16 19:21:45 -0800
commit58a15f3d5a2213d37bbf653e4562c36a130f14ee (patch)
tree37c40a6975868c01e858fd7edd2db9449120fcf3
parent80a3f453db387d02dcb596745731031e7a8c9048 (diff)
parent421d24582d278c510fcaa8a3918d4eeff739f556 (diff)
downloadrust-58a15f3d5a2213d37bbf653e4562c36a130f14ee.tar.gz
rust-58a15f3d5a2213d37bbf653e4562c36a130f14ee.zip
auto merge of #11584 : alexcrichton/rust/issue-3862, r=brson
Turns out there is no documentation of a block expression in the rust manual currently! I deleted the "record expressions" section to make room for a "block expressions" section.

Closes #3862
-rw-r--r--doc/rust.md22
1 files changed, 17 insertions, 5 deletions
diff --git a/doc/rust.md b/doc/rust.md
index ac0f64acca9..ad93964d6aa 100644
--- a/doc/rust.md
+++ b/doc/rust.md
@@ -806,7 +806,9 @@ path_glob : ident [ "::" path_glob ] ?
 
 A _use declaration_ creates one or more local name bindings synonymous
 with some other [path](#paths).
-Usually a `use` declaration is used to shorten the path required to refer to a module item.
+Usually a `use` declaration is used to shorten the path required to refer to a
+module item. These declarations may appear at the top of [modules](#modules) and
+[blocks](#blocks).
 
 *Note*: Unlike in many languages,
 `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};
 Point3d {y: 0, z: 10, .. base};
 ~~~~
 
-### Record expressions
+### Block expressions
 
 ~~~~ {.ebnf .gram}
-rec_expr : '{' ident ':' expr
-               [ ',' ident ':' expr ] *
-               [ ".." expr ] '}'
+block_expr : '{' [ view_item ] *
+                 [ stmt ';' | item ] *
+                 [ expr ] '}'
 ~~~~
 
+A _block expression_ is similar to a module in terms of the declarations that
+are possible. Each block conceptually introduces a new namespace scope. View
+items can bring new names into scopes and declared items are in scope for only
+the block itself.
+
+A block will execute each statement sequentially, and then execute the
+expression (if given). If the final expression is omitted, the type and return
+value of the block are `()`, but if it is provided, the type and return value
+of the block are that of the expression itself.
+
 ### Method-call expressions
 
 ~~~~ {.ebnf .gram}