File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -46,12 +46,19 @@ fn main() {
46
46
println!("The person's age from person struct is {}", person.age);
47
47
}
48
48
```
49
+ <!--
49
50
(In this example, we store the `age` variable on the heap to
50
51
illustrate the partial move: deleting `ref` in the above code would
51
52
give an error as the ownership of `person.age` would be moved to the
52
53
variable `age`. If `Person.age` were stored on the stack, `ref` would
53
54
not be required as the definition of `age` would copy the data from
54
55
`person.age` without moving it.)
56
+ -->
57
+ この例では、` age ` 変数をヒープ上に保持し、部分的ムーブを説明しています。
58
+ 上記コードで` ref ` を削除すると、` person.age ` の所有権が` age ` 変数にムーブされるため、エラーになります。
59
+ もしも` Person.age ` がスタック上に保持されていたら、
60
+ ` age ` の定義が` person.age ` をムーブすることなくデータをコピーするので、
61
+ ` ref ` は必須ではないのですが、実際にはヒープ上に保持されているため` ref ` は必須です。
55
62
56
63
<!--
57
64
### See also:
You can’t perform that action at this time.
0 commit comments