Skip to content

Commit b7f9baf

Browse files
committed
ch16 恐れるな!並行性の和訳を最新版に更新
rust-lang/book@19c40bf
1 parent 97d8397 commit b7f9baf

File tree

35 files changed

+440
-875
lines changed

35 files changed

+440
-875
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "threads"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]

listings/ch16-fearless-concurrency/listing-16-01/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ use std::time::Duration;
44
fn main() {
55
thread::spawn(|| {
66
for i in 1..10 {
7+
// "やあ!立ち上げたスレッドから数字{}だよ!"
78
println!("hi number {} from the spawned thread!", i);
89
thread::sleep(Duration::from_millis(1));
910
}
1011
});
1112

1213
for i in 1..5 {
14+
// "やあ!メインスレッドから数字{}だよ!"
1315
println!("hi number {} from the main thread!", i);
1416
thread::sleep(Duration::from_millis(1));
1517
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "threads"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "threads"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
$ cargo run
22
Compiling threads v0.1.0 (file:///projects/threads)
33
error[E0373]: closure may outlive the current function, but it borrows `v`, which is owned by the current function
4+
(エラー: クロージャは現在の関数よりも長生きするかもしれませんが、現在の関数が所有している`v`を借用しています)
45
--> src/main.rs:6:32
56
|
67
6 | let handle = thread::spawn(|| {
78
| ^^ may outlive borrowed value `v`
9+
| (借用されている値`v`より長生きするかもしれません)
810
7 | println!("Here's a vector: {:?}", v);
911
| - `v` is borrowed here
12+
| (`v`はここで借用されています)
1013
|
1114
note: function requires argument type to outlive `'static`
15+
(注釈: 関数は引数型が`'static`より長生きすることを要求しています)
1216
--> src/main.rs:6:18
1317
|
1418
6 | let handle = thread::spawn(|| {
@@ -17,13 +21,10 @@ note: function requires argument type to outlive `'static`
1721
8 | | });
1822
| |______^
1923
help: to force the closure to take ownership of `v` (and any other referenced variables), use the `move` keyword
24+
(ヘルプ: `v`(や他の参照されている変数)の所有権をクロージャに奪わせるには、`move`キーワードを使用してください)
2025
|
2126
6 | let handle = thread::spawn(move || {
22-
| ^^^^^^^
23-
24-
error: aborting due to previous error
27+
| ++++
2528

2629
For more information about this error, try `rustc --explain E0373`.
27-
error: could not compile `threads`.
28-
29-
To learn more, run the command again with --verbose.
30+
error: could not compile `threads` (bin "threads") due to 1 previous error

listings/ch16-fearless-concurrency/listing-16-03/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ fn main() {
44
let v = vec![1, 2, 3];
55

66
let handle = thread::spawn(|| {
7+
// "こちらがベクタ: {:?}"
78
println!("Here's a vector: {:?}", v);
89
});
910

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "threads"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]

listings/ch16-fearless-concurrency/listing-16-04/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77
println!("Here's a vector: {:?}", v);
88
});
99

10-
drop(v); // oh no!
10+
drop(v); // あちゃー!
1111

1212
handle.join().unwrap();
1313
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "threads"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "message-passing"
33
version = "0.1.0"
4-
authors = ["Your Name <[email protected]>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]

0 commit comments

Comments
 (0)