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.
388
388
他方で、 ` *mut ` は、共有の有無に関わらず ` &mut ` に参照外し可能です。よって
389
389
` *mut ` は cell と同じように非変性です。
390
390
391
+ <!--
391
392
This is all well and good for the types the standard library provides, but
392
393
how is variance determined for type that *you* define? A struct, informally
393
394
speaking, inherits the variance of its fields. If a struct `Foo`
394
395
has a generic argument `A` that is used in a field `a`, then Foo's variance
395
396
over `A` is exactly `a`'s variance. However this is complicated if `A` is used
396
397
in multiple fields.
398
+ -->
399
+
400
+ これは標準ライブラリが提供する型にとっては上手くいくのですが、
401
+ * あなたが* 定義した型の変性はどのように決定されるのでしょうか? 簡単に言えば、
402
+ 構造体はフィールドの変性を受け継ぎます。もし構造体 ` Foo ` が、フィールド ` a ` に使われる
403
+ ジェネリックな引数 ` A ` を持つならば、 Foo の ` A ` における変性は ` a ` の変性と全く同じです。
404
+ しかしながら、もし ` A ` が複数のフィールドで使用されている場合、これは複雑になります。
397
405
398
406
* If all uses of A are variant, then Foo is variant over A
399
407
* Otherwise, Foo is invariant over A
You can’t perform that action at this time.
0 commit comments