@@ -265,10 +265,12 @@ fail:
265
265
<span class =" filename " >ファイル名: src/main.rs</span >
266
266
267
267
``` rust,ignore
268
- let mut s = String::from("hello");
268
+ let mut s = String::from("hello");
269
269
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);
272
274
```
273
275
274
276
<!--
@@ -278,19 +280,28 @@ Here’s the error:
278
280
これがエラーです:
279
281
280
282
``` text
283
+ $ cargo run
284
+ Compiling ownership v0.1.0 (file:///projects/ownership)
281
285
error[E0499]: cannot borrow `s` as mutable more than once at a time
282
286
(エラー: 一度に`s`を可変として2回以上借用することはできません)
283
- --> borrow_twice .rs:5:19
287
+ --> src/main .rs:5:14
284
288
|
285
289
4 | let r1 = &mut s;
286
- | - first mutable borrow occurs here
290
+ | ----- - first mutable borrow occurs here
287
291
| (最初の可変な参照はここ)
288
292
5 | let r2 = &mut s;
289
- | ^ second mutable borrow occurs here
293
+ | ^^^^^ ^ second mutable borrow occurs here
290
294
| (二つ目の可変な参照はここ)
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.
294
305
```
295
306
296
307
<!--
0 commit comments