Skip to content

Commit 0a76468

Browse files
authored
Merge pull request #177 from kdnakt/translate-partial_move
Translate untranslated lines in partial_move.md
2 parents 851792a + 2b7608a commit 0a76468

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/scope/move/partial_move.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,19 @@ fn main() {
4646
println!("The person's age from person struct is {}", person.age);
4747
}
4848
```
49+
<!--
4950
(In this example, we store the `age` variable on the heap to
5051
illustrate the partial move: deleting `ref` in the above code would
5152
give an error as the ownership of `person.age` would be moved to the
5253
variable `age`. If `Person.age` were stored on the stack, `ref` would
5354
not be required as the definition of `age` would copy the data from
5455
`person.age` without moving it.)
56+
-->
57+
この例では、`age`変数をヒープ上に保持し、部分的ムーブを説明しています。
58+
上記コードで`ref`を削除すると、`person.age`の所有権が`age`変数にムーブされるため、エラーになります。
59+
もしも`Person.age`がスタック上に保持されていたら、
60+
`age`の定義が`person.age`をムーブすることなくデータをコピーするので、
61+
`ref`は必須ではないのですが、実際にはヒープ上に保持されているため`ref`は必須です。
5562

5663
<!--
5764
### See also:

0 commit comments

Comments
 (0)