File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -225,12 +225,21 @@ invariant.
225
225
変性か非変性かの一般的な主題はこちらです: もし変性によって、短く生きる値がより長く生きる
226
226
スロットに保存されるようなことが起きてしまうならば、非変性でなければなりません。
227
227
228
+ <!--
228
229
However it *is* sound for `&'a mut T` to be variant over `'a`. The key difference
229
230
between `'a` and T is that `'a` is a property of the reference itself,
230
231
while T is something the reference is borrowing. If you change T's type, then
231
232
the source still remembers the original type. However if you change the
232
233
lifetime's type, no one but the reference knows this information, so it's fine.
233
234
Put another way: `&'a mut T` owns `'a`, but only *borrows* T.
235
+ -->
236
+
237
+ しかし、 ` &'a mut T ` は ` 'a ` において変性のように* 見えます* 。 ` &'a ` と T の
238
+ 重要な違いは、 ` 'a ` は参照それ自体の性質ですが、 T は参照が借用しているものということです。
239
+ もし T の型を変えても、借用元は元の型を記憶しています。
240
+ しかし、もしライフタイムの型を変えると、参照以外のものはこの情報を記憶していないので、
241
+ 問題ないのです。
242
+ 言い換えると、 ` &'a mut T ` は ` 'a ` を所有しますが、 T は単に* 借用している* だけなのです。
234
243
235
244
` Box ` and ` Vec ` are interesting cases because they're variant, but you can
236
245
definitely store values in them! This is where Rust gets really clever: it's
You can’t perform that action at this time.
0 commit comments