Skip to content

Commit bcfaa2d

Browse files
author
taku-a11y
authored
###可変な参照 のコードとエラー文を原文に統一
エラー出力の内容が異なるので、コードとエラー文を原文と同じものにした。翻訳はまだしていない。 原文:https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html
1 parent 771c4e2 commit bcfaa2d

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/ch04-02-references-and-borrowing.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,12 @@ fail:
265265
<span class="filename">ファイル名: src/main.rs</span>
266266

267267
```rust,ignore
268-
let mut s = String::from("hello");
268+
let mut s = String::from("hello");
269269
270-
let r1 = &mut s;
271-
let r2 = &mut s;
270+
let r1 = &mut s;
271+
let r2 = &mut s;
272+
273+
println!("{}, {}", r1, r2);
272274
```
273275

274276
<!--
@@ -278,19 +280,28 @@ Here’s the error:
278280
これがエラーです:
279281

280282
```text
283+
$ cargo run
284+
Compiling ownership v0.1.0 (file:///projects/ownership)
281285
error[E0499]: cannot borrow `s` as mutable more than once at a time
282286
(エラー: 一度に`s`を可変として2回以上借用することはできません)
283-
--> borrow_twice.rs:5:19
287+
--> src/main.rs:5:14
284288
|
285289
4 | let r1 = &mut s;
286-
| - first mutable borrow occurs here
290+
| ------ first mutable borrow occurs here
287291
| (最初の可変な参照はここ)
288292
5 | let r2 = &mut s;
289-
| ^ second mutable borrow occurs here
293+
| ^^^^^^ second mutable borrow occurs here
290294
| (二つ目の可変な参照はここ)
291-
6 | }
292-
| - first borrow ends here
293-
| (最初の借用はここで終わり)
295+
6 |
296+
7 | println!("{}, {}", r1, r2);
297+
| -- first borrow later used here
298+
299+
error: aborting due to previous error
300+
301+
For more information about this error, try `rustc --explain E0499`.
302+
error: could not compile `ownership`
303+
304+
To learn more, run the command again with --verbose.
294305
```
295306

296307
<!--

0 commit comments

Comments
 (0)