Skip to content

Commit 14ce607

Browse files
committed
Auto merge of #23200 - Manishearth:rollup, r=Manishearth
2 parents 36c3612 + 3797827 commit 14ce607

File tree

8 files changed

+47
-21
lines changed

8 files changed

+47
-21
lines changed

src/doc/grammar.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ field_expr : expr '.' ident ;
514514
### Array expressions
515515

516516
```antlr
517-
array_expr : '[' "mut" ? vec_elems? ']' ;
517+
array_expr : '[' "mut" ? array_elems? ']' ;
518518
519519
array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
520520
```

src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2847,7 +2847,7 @@ automatically dereferenced to make the field access possible.
28472847
### Array expressions
28482848

28492849
```{.ebnf .gram}
2850-
array_expr : '[' "mut" ? vec_elems? ']' ;
2850+
array_expr : '[' "mut" ? array_elems? ']' ;
28512851
28522852
array_elems : [expr [',' expr]*] | [expr ';' expr] ;
28532853
```

src/doc/trpl/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
* [Standard Input](standard-input.md)
1717
* [Guessing Game](guessing-game.md)
1818
* [II: Intermediate Rust](intermediate.md)
19-
* [More Strings](more-strings.md)
2019
* [Crates and Modules](crates-and-modules.md)
2120
* [Testing](testing.md)
2221
* [Pointers](pointers.md)
2322
* [Ownership](ownership.md)
23+
* [More Strings](more-strings.md)
2424
* [Patterns](patterns.md)
2525
* [Method Syntax](method-syntax.md)
2626
* [Closures](closures.md)

src/doc/trpl/concurrency.md

+2-9
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,8 @@ method which has this signature:
223223
fn lock(&self) -> LockResult<MutexGuard<T>>
224224
```
225225

226-
If we [look at the code for MutexGuard](https://github.com/rust-lang/rust/blob/ca4b9674c26c1de07a2042cb68e6a062d7184cef/src/libstd/sync/mutex.rs#L172), we'll see
227-
this:
228-
229-
```ignore
230-
__marker: marker::NoSend,
231-
```
232-
233-
Because our guard is `NoSend`, it's not `Send`. Which means we can't actually
234-
transfer the guard across thread boundaries, which gives us our error.
226+
Because `Send` is not implemented for `MutexGuard<T>`, we can't transfer the
227+
guard across thread boundaries, which gives us our error.
235228

236229
We can use `Arc<T>` to fix this. Here's the working version:
237230

src/doc/trpl/method-syntax.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,29 @@ You can think of this first parameter as being the `x` in `x.foo()`. The three
5050
variants correspond to the three kinds of thing `x` could be: `self` if it's
5151
just a value on the stack, `&self` if it's a reference, and `&mut self` if it's
5252
a mutable reference. We should default to using `&self`, as it's the most
53-
common.
53+
common. Here's an example of all three variants:
54+
55+
```rust
56+
struct Circle {
57+
x: f64,
58+
y: f64,
59+
radius: f64,
60+
}
61+
62+
impl Circle {
63+
fn reference(&self) {
64+
println!("taking self by reference!");
65+
}
66+
67+
fn mutable_reference(&mut self) {
68+
println!("taking self by mutable reference!");
69+
}
70+
71+
fn takes_ownership(self) {
72+
println!("taking ownership of self!");
73+
}
74+
}
75+
```
5476

5577
Finally, as you may remember, the value of the area of a circle is `π*r²`.
5678
Because we took the `&self` parameter to `area`, we can use it just like any

src/doc/trpl/more-strings.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,18 @@ This will print:
278278

279279
Many more bytes than graphemes!
280280

281-
# Other Documentation
281+
# `Deref` coercions
282282

283-
* [the `&str` API documentation](../std/str/index.html)
284-
* [the `String` API documentation](../std/string/index.html)
283+
References to `String`s will automatically coerce into `&str`s. Like this:
284+
285+
```
286+
fn hello(s: &str) {
287+
println!("Hello, {}!", s);
288+
}
289+
290+
let slice = "Steve";
291+
let string = "Steve".to_string();
292+
293+
hello(slice);
294+
hello(&string);
295+
```

src/doc/trpl/pointers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@ use-case for boxes.
634634
### Returning data
635635

636636
This is important enough to have its own section entirely. The TL;DR is this:
637-
you don't generally want to return pointers, even when you might in a language
638-
like C or C++.
637+
you don't want to return pointers, even when you might in a language like C or
638+
C++.
639639

640640
See [Returning Pointers](#returning-pointers) below for more.
641641

src/libstd/process.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl Command {
264264
/// By default, stdin, stdout and stderr are captured (and used to
265265
/// provide the resulting output).
266266
///
267-
/// # Example
267+
/// # Examples
268268
///
269269
/// ```
270270
/// # #![feature(process)]
@@ -275,8 +275,8 @@ impl Command {
275275
/// });
276276
///
277277
/// println!("status: {}", output.status);
278-
/// println!("stdout: {}", String::from_utf8_lossy(output.stdout.as_slice()));
279-
/// println!("stderr: {}", String::from_utf8_lossy(output.stderr.as_slice()));
278+
/// println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
279+
/// println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
280280
/// ```
281281
#[stable(feature = "process", since = "1.0.0")]
282282
pub fn output(&mut self) -> io::Result<Output> {

0 commit comments

Comments
 (0)