Skip to content

Commit 46a06ad

Browse files
committed
ch19 高度な機能の和訳を最新版に更新
rust-lang/book@19c40bf
1 parent 7f4328c commit 46a06ad

File tree

86 files changed

+957
-1265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+957
-1265
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[package]
22
name = "unsafe-example"
33
version = "0.1.0"
4-
authors = ["Your Name <you@example.com>"]
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 = "unsafe-example"
33
version = "0.1.0"
4-
authors = ["Your Name <you@example.com>"]
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 = "unsafe-example"
33
version = "0.1.0"
4-
authors = ["Your Name <you@example.com>"]
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 = "unsafe-example"
33
version = "0.1.0"
4-
authors = ["Your Name <you@example.com>"]
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 = "unsafe-example"
33
version = "0.1.0"
4-
authors = ["Your Name <you@example.com>"]
5-
edition = "2018"
4+
edition = "2021"
65

76
[dependencies]
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
$ cargo run
22
Compiling unsafe-example v0.1.0 (file:///projects/unsafe-example)
3-
error[E0499]: cannot borrow `*slice` as mutable more than once at a time
4-
--> src/main.rs:6:30
3+
error[E0499]: cannot borrow `*values` as mutable more than once at a time
4+
(エラー: 一度に2回以上、`*values`を可変で借用できません)
5+
--> src/main.rs:6:31
56
|
6-
1 | fn split_at_mut(slice: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
7-
| - let's call the lifetime of this reference `'1`
7+
1 | fn split_at_mut(values: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
8+
| - let's call the lifetime of this reference `'1`
9+
| (この参照のライフタイムを`'1`とします)
810
...
9-
6 | (&mut slice[..mid], &mut slice[mid..])
10-
| -------------------------^^^^^--------
11-
| | | |
12-
| | | second mutable borrow occurs here
11+
6 | (&mut values[..mid], &mut values[mid..])
12+
| --------------------------^^^^^^--------
13+
| | | |
14+
| | | second mutable borrow occurs here
15+
| | | (2回目の可変参照はここで発生します)
1316
| | first mutable borrow occurs here
14-
| returning this value requires that `*slice` is borrowed for `'1`
15-
16-
error: aborting due to previous error
17+
| | (1回目の可変参照はここで発生します)
18+
| returning this value requires that `*values` is borrowed for `'1`
19+
| (この値を返すためには`*values`が`'1`の間借用されていることが必要です)
1720

1821
For more information about this error, try `rustc --explain E0499`.
19-
error: could not compile `unsafe-example`.
20-
21-
To learn more, run the command again with --verbose.
22+
error: could not compile `unsafe-example` (bin "unsafe-example") due to 1 previous error

listings/ch19-advanced-features/listing-19-05/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// ANCHOR: here
2-
fn split_at_mut(slice: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
3-
let len = slice.len();
2+
fn split_at_mut(values: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
3+
let len = values.len();
44

55
assert!(mid <= len);
66

7-
(&mut slice[..mid], &mut slice[mid..])
7+
(&mut values[..mid], &mut values[mid..])
88
}
99
// ANCHOR_END: here
1010

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

76
[dependencies]

listings/ch19-advanced-features/listing-19-06/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// ANCHOR: here
22
use std::slice;
33

4-
fn split_at_mut(slice: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
5-
let len = slice.len();
6-
let ptr = slice.as_mut_ptr();
4+
fn split_at_mut(values: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) {
5+
let len = values.len();
6+
let ptr = values.as_mut_ptr();
77

88
assert!(mid <= len);
99

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

76
[dependencies]

0 commit comments

Comments
 (0)