@@ -31,17 +31,21 @@ fn main() {
31
31
// ミュータブルに借用することができない。
32
32
// let mutable_borrow = &mut point;
33
33
// TODO ^ Try uncommenting this line
34
+ // TODO ^ この行をアンコメントしてみましょう。
34
35
35
36
// The borrowed values are used again here
37
+ // 借用された値はここで再び利用されます。
36
38
println!("Point has coordinates: ({}, {}, {})",
37
39
borrowed_point.x, another_borrow.y, point.z);
38
40
39
41
// The immutable references are no longer used for the rest of the code so
40
42
// it is possible to reborrow with a mutable reference.
43
+ // イミュータブルな参照がこれ以降のコードで利用されていないため、
44
+ // ミュータブルな参照として再借用できます。
41
45
let mutable_borrow = &mut point;
42
46
43
47
// Change data via mutable reference
44
- // ミュータブルなリファレンスを介してデータを変更する
48
+ // ミュータブルな参照を介してデータを変更する
45
49
mutable_borrow.x = 5;
46
50
mutable_borrow.y = 2;
47
51
mutable_borrow.z = 1;
@@ -55,17 +59,19 @@ fn main() {
55
59
// TODO ^ この行をアンコメントしてみましょう。
56
60
57
61
// Error! Can't print because `println!` takes an immutable reference.
58
- // エラー!`println!`はイミュータブルなリファレンスを取るため 、printできません。
62
+ // エラー!`println!`はイミュータブルな参照を取るため 、printできません。
59
63
// println!("Point Z coordinate is {}", point.z);
60
64
// TODO ^ Try uncommenting this line
61
65
// TODO ^ この行をアンコメントしてみましょう。
62
66
63
67
// Ok! Mutable references can be passed as immutable to `println!`
68
+ // OK!ミュータブルな参照は`println!`にイミュータブルな参照として渡せます。
64
69
println!("Point has coordinates: ({}, {}, {})",
65
70
mutable_borrow.x, mutable_borrow.y, mutable_borrow.z);
66
71
67
72
// The mutable reference is no longer used for the rest of the code so it
68
73
// is possible to reborrow
74
+ // ミュータブルな参照がこれ以降のコードで利用されていないため、再借用できます。
69
75
let new_borrowed_point = &point;
70
76
println!("Point now has coordinates: ({}, {}, {})",
71
77
new_borrowed_point.x, new_borrowed_point.y, new_borrowed_point.z);
0 commit comments