Skip to content

Commit 32c3a26

Browse files
committed
---
yaml --- r: 185643 b: refs/heads/master c: c9d5494 h: refs/heads/master i: 185641: d3845eb 185639: c52504d v: v3
1 parent f00b557 commit 32c3a26

File tree

5 files changed

+31
-37
lines changed

5 files changed

+31
-37
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: fe91974dd6eb3c16cc80081d6eb9f7017eb6bada
2+
refs/heads/master: c9d54946403f42a1a771ed2649b80996c49bb6b3
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 3a96d6a9818fe2affc98a187fb1065120458cee9
55
refs/heads/try: ccf8fedf1cffcb8f6f3581d53d220039e192fe77

trunk/src/doc/intro.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,10 @@ numbers[1] is 3
510510
numbers[0] is 2
511511
```
512512
513-
Each time, we can get a slithtly different output because the threads
514-
are not quaranteed to run in any set order. If you get the same order
515-
every time it is because each of these threads are very small and
516-
complete too fast for their indeterminate behavior to surface.
513+
Each time, we can get a slightly different output because the threads are not
514+
guaranteed to run in any set order. If you get the same order every time it is
515+
because each of these threads are very small and complete too fast for their
516+
indeterminate behavior to surface.
517517
518518
The important part here is that the Rust compiler was able to use ownership to
519519
give us assurance _at compile time_ that we weren't doing something incorrect

trunk/src/doc/trpl/guessing-game.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,11 @@ In this case, we say `x` is a `u32` explicitly, so Rust is able to properly
422422
tell `random()` what to generate. In a similar fashion, both of these work:
423423
424424
```{rust,ignore}
425-
let input_num = "5".parse::<u32>(); // input_num: Option<u32>
426-
let input_num: Result<u32, _> = "5".parse(); // input_num: Result<u32, <u32 as FromStr>::Err>
425+
let input_num_option = "5".parse::<u32>().ok(); // input_num: Option<u32>
426+
let input_num_result: Result<u32, _> = "5".parse(); // input_num: Result<u32, <u32 as FromStr>::Err>
427427
```
428428
429-
Here we're converting the `Result` returned by `parse` to an `Option` by using
429+
Above, we're converting the `Result` returned by `parse` to an `Option` by using
430430
the `ok` method as well. Anyway, with us now converting our input to a number,
431431
our code looks like this:
432432
@@ -470,14 +470,14 @@ Let's try it out!
470470
```bash
471471
$ cargo build
472472
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
473-
src/main.rs:22:15: 22:24 error: mismatched types: expected `u32` but found `core::option::Option<u32>` (expected u32 but found enum core::option::Option)
474-
src/main.rs:22 match cmp(input_num, secret_number) {
473+
src/main.rs:21:15: 21:24 error: mismatched types: expected `u32`, found `core::result::Result<u32, core::num::ParseIntError>` (expected u32, found enum `core::result::Result`) [E0308]
474+
src/main.rs:21 match cmp(input_num, secret_number) {
475475
^~~~~~~~~
476476
error: aborting due to previous error
477477
```
478478
479-
Oh yeah! Our `input_num` has the type `Option<u32>`, rather than `u32`. We
480-
need to unwrap the Option. If you remember from before, `match` is a great way
479+
Oh yeah! Our `input_num` has the type `Result<u32, <some error>>`, rather than `u32`. We
480+
need to unwrap the Result. If you remember from before, `match` is a great way
481481
to do that. Try this code:
482482
483483
```{rust,no_run}
@@ -500,7 +500,7 @@ fn main() {
500500
let input_num: Result<u32, _> = input.parse();
501501

502502
let num = match input_num {
503-
Ok(num) => num,
503+
Ok(n) => n,
504504
Err(_) => {
505505
println!("Please input a number!");
506506
return;
@@ -524,7 +524,7 @@ fn cmp(a: u32, b: u32) -> Ordering {
524524
}
525525
```
526526
527-
We use a `match` to either give us the `u32` inside of the `Option`, or else
527+
We use a `match` to either give us the `u32` inside of the `Result`, or else
528528
print an error message and return. Let's give this a shot:
529529
530530
```bash

trunk/src/libcollections/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@
364364
//! * `o` - precedes the argument with a "0o"
365365
//! * '0' - This is used to indicate for integer formats that the padding should
366366
//! both be done with a `0` character as well as be sign-aware. A format
367-
//! like `{:08d}` would yield `00000001` for the integer `1`, while the
367+
//! like `{:08}` would yield `00000001` for the integer `1`, while the
368368
//! same format would yield `-0000001` for the integer `-1`. Notice that
369369
//! the negative version has one fewer zero than the positive version.
370370
//!

trunk/src/libstd/thread.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@
2828
//! a thread will unwind the stack, running destructors and freeing
2929
//! owned resources. Thread panic is unrecoverable from within
3030
//! the panicking thread (i.e. there is no 'try/catch' in Rust), but
31-
//! panic may optionally be detected from a different thread. If
32-
//! the main thread panics the application will exit with a non-zero
31+
//! the panic may optionally be detected from a different thread. If
32+
//! the main thread panics, the application will exit with a non-zero
3333
//! exit code.
3434
//!
3535
//! When the main thread of a Rust program terminates, the entire program shuts
3636
//! down, even if other threads are still running. However, this module provides
3737
//! convenient facilities for automatically waiting for the termination of a
38-
//! child thread (i.e., join), described below.
38+
//! child thread (i.e., join).
3939
//!
4040
//! ## The `Thread` type
4141
//!
42-
//! Already-running threads are represented via the `Thread` type, which you can
42+
//! Threads are represented via the `Thread` type, which you can
4343
//! get in one of two ways:
4444
//!
45-
//! * By spawning a new thread, e.g. using the `thread::spawn` constructor;
45+
//! * By spawning a new thread, e.g. using the `thread::spawn` function.
4646
//! * By requesting the current thread, using the `thread::current` function.
4747
//!
4848
//! Threads can be named, and provide some built-in support for low-level
49-
//! synchronization described below.
49+
//! synchronization (described below).
5050
//!
5151
//! The `thread::current()` function is available even for threads not spawned
5252
//! by the APIs of this module.
@@ -59,29 +59,27 @@
5959
//! use std::thread;
6060
//!
6161
//! thread::spawn(move || {
62-
//! println!("Hello, World!");
63-
//! // some computation here
62+
//! // some work here
6463
//! });
6564
//! ```
6665
//!
6766
//! In this example, the spawned thread is "detached" from the current
68-
//! thread, meaning that it can outlive the thread that spawned
69-
//! it. (Note, however, that when the main thread terminates all
70-
//! detached threads are terminated as well.)
67+
//! thread. This means that it can outlive its parent (the thread that spawned
68+
//! it), unless this parent is the main thread.
7169
//!
7270
//! ## Scoped threads
7371
//!
7472
//! Often a parent thread uses a child thread to perform some particular task,
7573
//! and at some point must wait for the child to complete before continuing.
76-
//! For this scenario, use the `scoped` constructor:
74+
//! For this scenario, use the `thread::scoped` function:
7775
//!
7876
//! ```rust
7977
//! use std::thread;
8078
//!
8179
//! let guard = thread::scoped(move || {
82-
//! println!("Hello, World!");
83-
//! // some computation here
80+
//! // some work here
8481
//! });
82+
//!
8583
//! // do some other work in the meantime
8684
//! let output = guard.join();
8785
//! ```
@@ -92,11 +90,7 @@
9290
//! terminates) when it is dropped. You can join the child thread in
9391
//! advance by calling the `join` method on the guard, which will also
9492
//! return the result produced by the thread. A handle to the thread
95-
//! itself is available via the `thread` method on the join guard.
96-
//!
97-
//! (Note: eventually, the `scoped` constructor will allow the parent and child
98-
//! threads to data that lives on the parent thread's stack, but some language
99-
//! changes are needed before this is possible.)
93+
//! itself is available via the `thread` method of the join guard.
10094
//!
10195
//! ## Configuring threads
10296
//!
@@ -108,7 +102,7 @@
108102
//! use std::thread;
109103
//!
110104
//! thread::Builder::new().name("child1".to_string()).spawn(move || {
111-
//! println!("Hello, world!")
105+
//! println!("Hello, world!");
112106
//! });
113107
//! ```
114108
//!
@@ -121,7 +115,7 @@
121115
//! initially not present:
122116
//!
123117
//! * The `thread::park()` function blocks the current thread unless or until
124-
//! the token is available for its thread handle, at which point It atomically
118+
//! the token is available for its thread handle, at which point it atomically
125119
//! consumes the token. It may also return *spuriously*, without consuming the
126120
//! token. `thread::park_timeout()` does the same, but allows specifying a
127121
//! maximum time to block the thread for.
@@ -143,7 +137,7 @@
143137
//! * It avoids the need to allocate mutexes and condvars when building new
144138
//! synchronization primitives; the threads already provide basic blocking/signaling.
145139
//!
146-
//! * It can be implemented highly efficiently on many platforms.
140+
//! * It can be implemented very efficiently on many platforms.
147141
148142
#![stable(feature = "rust1", since = "1.0.0")]
149143

0 commit comments

Comments
 (0)