File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -388,12 +388,20 @@ as invariant just like cells.
388388他方で、 ` *mut ` は、共有の有無に関わらず ` &mut ` に参照外し可能です。よって
389389` *mut ` は cell と同じように非変性です。
390390
391+ <!--
391392This is all well and good for the types the standard library provides, but
392393how is variance determined for type that *you* define? A struct, informally
393394speaking, inherits the variance of its fields. If a struct `Foo`
394395has a generic argument `A` that is used in a field `a`, then Foo's variance
395396over `A` is exactly `a`'s variance. However this is complicated if `A` is used
396397in multiple fields.
398+ -->
399+
400+ これは標準ライブラリが提供する型にとっては上手くいくのですが、
401+ * あなたが* 定義した型の変性はどのように決定されるのでしょうか? 簡単に言えば、
402+ 構造体はフィールドの変性を受け継ぎます。もし構造体 ` Foo ` が、フィールド ` a ` に使われる
403+ ジェネリックな引数 ` A ` を持つならば、 Foo の ` A ` における変性は ` a ` の変性と全く同じです。
404+ しかしながら、もし ` A ` が複数のフィールドで使用されている場合、これは複雑になります。
397405
398406* If all uses of A are variant, then Foo is variant over A
399407* Otherwise, Foo is invariant over A
You can’t perform that action at this time.
0 commit comments