diff options
| author | bors <bors@rust-lang.org> | 2014-09-09 20:16:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-09-09 20:16:19 +0000 |
| commit | 651106462c357b71a4ca2c02ba2bfedfc38b0035 (patch) | |
| tree | 79cd7984fb470f273f5907c579a2db5f71296c7e /src/doc | |
| parent | b625d43f8fd2e9a800ca8a419f7d3f5f52604205 (diff) | |
| parent | e5abe15ff55212c60fc4acc9bfc2bc79038507b8 (diff) | |
| download | rust-651106462c357b71a4ca2c02ba2bfedfc38b0035.tar.gz rust-651106462c357b71a4ca2c02ba2bfedfc38b0035.zip | |
auto merge of #17127 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/guide.md | 13 | ||||
| -rw-r--r-- | src/doc/rust.md | 14 | ||||
| -rw-r--r-- | src/doc/tutorial.md | 2 |
3 files changed, 11 insertions, 18 deletions
diff --git a/src/doc/guide.md b/src/doc/guide.md index e4bb3ae6ba6..6d0fd54cd4c 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -520,10 +520,8 @@ error: aborting due to previous error Could not compile `hello_world`. ``` -Rust will not let us use a value that has not been initialized. So why let us -declare a binding without initializing it? You'd think our first example would -have errored. Well, Rust is smarter than that. Before we get to that, let's talk -about this stuff we've added to `println!`. +Rust will not let us use a value that has not been initialized. Next, let's +talk about this stuff we've added to `println!`. If you include two curly braces (`{}`, some call them moustaches...) in your string to print, Rust will interpret this as a request to interpolate some sort @@ -538,12 +536,6 @@ format in a more detailed manner, there are a [wide number of options available](std/fmt/index.html). For now, we'll just stick to the default: integers aren't very complicated to print. -So, we've cleared up all of the confusion around bindings, with one exception: -why does Rust let us declare a variable binding without an initial value if we -must initialize the binding before we use it? And how does it know that we have -or have not initialized the binding? For that, we need to learn our next -concept: `if`. - # If Rust's take on `if` is not particularly complex, but it's much more like the @@ -582,7 +574,6 @@ if x == 5i { This is all pretty standard. However, you can also do this: - ``` let x = 5i; diff --git a/src/doc/rust.md b/src/doc/rust.md index 86776d50e79..eb97a75e766 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -3290,17 +3290,19 @@ between `_` and `..` is that the pattern `C(_)` is only type-correct if `C` has exactly one argument, while the pattern `C(..)` is type-correct for any enum variant `C`, regardless of how many arguments `C` has. -Used inside a vector pattern, `..` stands for any number of elements. This -wildcard can be used at most once for a given vector, which implies that it -cannot be used to specifically match elements that are at an unknown distance -from both ends of a vector, like `[.., 42, ..]`. If followed by a variable name, -it will bind the corresponding slice to the variable. Example: +Used inside a vector pattern, `..` stands for any number of elements, when the +`advanced_slice_patterns` feature gate is turned on. This wildcard can be used +at most once for a given vector, which implies that it cannot be used to +specifically match elements that are at an unknown distance from both ends of a +vector, like `[.., 42, ..]`. If followed by a variable name, it will bind the +corresponding slice to the variable. Example: ~~~~ +# #![feature(advanced_slice_patterns)] fn is_symmetric(list: &[uint]) -> bool { match list { [] | [_] => true, - [x, ..inside, y] if x == y => is_symmetric(inside), + [x, inside.., y] if x == y => is_symmetric(inside), _ => false } } diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 0db25c4090e..0e5a624b273 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -1707,7 +1707,7 @@ let score = match numbers { [] => 0, [a] => a * 10, [a, b] => a * 6 + b * 4, - [a, b, c, ..rest] => a * 5 + b * 3 + c * 2 + rest.len() as int + [a, b, c, rest..] => a * 5 + b * 3 + c * 2 + rest.len() as int }; ~~~~ |
