diff options
| author | Diggory Hardy <git@dhardy.name> | 2017-05-09 19:34:00 +0100 |
|---|---|---|
| committer | Diggory Hardy <git@dhardy.name> | 2017-05-09 19:34:00 +0100 |
| commit | 7488ff5c44f8e7515aa68e43011784de0893a6a6 (patch) | |
| tree | f9ebf6532e83416a54a3d8634d43841b0e00de3d | |
| parent | 7d94b4804a51ec7da42ddf3ff4a6bed0518319f7 (diff) | |
| download | rust-7488ff5c44f8e7515aa68e43011784de0893a6a6.tar.gz rust-7488ff5c44f8e7515aa68e43011784de0893a6a6.zip | |
loop_break_value book doc: remove some curiosities, regarding leodasvacas's comments
| -rw-r--r-- | src/doc/unstable-book/src/language-features/loop-break-value.md | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/doc/unstable-book/src/language-features/loop-break-value.md b/src/doc/unstable-book/src/language-features/loop-break-value.md index dae04d737b7..7218cad1c22 100644 --- a/src/doc/unstable-book/src/language-features/loop-break-value.md +++ b/src/doc/unstable-book/src/language-features/loop-break-value.md @@ -10,19 +10,9 @@ Documentation to be appended to section G of the book. ### Loops as expressions -Like most things in Rust, loops are expressions; for example, the following is perfectly legal, -if rather useless: - -```rust -let result = for n in 1..4 { - println!("Hello, {}", n); -}; -assert_eq!(result, ()); -``` - -Until now, all the loops you have seen evaluate to either `()` or `!`, the latter being special -syntax for "no value", meaning the loop never exits. A `loop` can instead evaluate to -a useful value via *break with value*: +Like most things in Rust, loops are expressions, and have a value; normally `()` unless the loop +never exits. +A `loop` can instead evaluate to a useful value via *break with value*: ```rust // Find the first square number over 1000: |
