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.
225225変性か非変性かの一般的な主題はこちらです: もし変性によって、短く生きる値がより長く生きる
226226スロットに保存されるようなことが起きてしまうならば、非変性でなければなりません。
227227
228+ <!--
228229However it *is* sound for `&'a mut T` to be variant over `'a`. The key difference
229230between `'a` and T is that `'a` is a property of the reference itself,
230231while T is something the reference is borrowing. If you change T's type, then
231232the source still remembers the original type. However if you change the
232233lifetime's type, no one but the reference knows this information, so it's fine.
233234Put 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 は単に* 借用している* だけなのです。
234243
235244` Box ` and ` Vec ` are interesting cases because they're variant, but you can
236245definitely 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