File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -101,15 +101,23 @@ subtyping of its outputs. There are two kinds of variance in Rust:
101
101
-->
102
102
103
103
* もし ` T ` が ` U ` の派生型である時、 ` F<T> ` が ` F<U> ` の派生型であるならば、 ` F ` は
104
- * 変性* です。(派生型の「パススルー」)
104
+ ` T ` において * 変性* です。(派生型の「パススルー」)
105
105
* それ以外の場合、 ` T ` は* 非変性* です。(いかなる派生型の関係も継承されません)
106
106
107
+ <!--
107
108
(For those of you who are familiar with variance from other languages, what we
108
109
refer to as "just" variance is in fact *covariance*. Rust has *contravariance*
109
110
for functions. The future of contravariance is uncertain and it may be
110
111
scrapped. For now, `fn(T)` is contravariant in `T`, which is used in matching
111
112
methods in trait implementations to the trait definition. Traits don't have
112
113
inferred variance, so `Fn(T)` is invariant in `T`).
114
+ -->
115
+
116
+ (他の言語で変性に慣れている方にとって、「単に」変性と言及しているものは実は* 共変性* です。
117
+ Rust では関数に* 反変性* が存在します。将来的に反変性がどうなるかは未定で、
118
+ 反変性が廃止されるかもしれません。今の所、 ` fn(T) ` は ` T ` の反変性で、これは
119
+ トレイトの定義に対してトレイトの実装内のメソッドをマッチさせるのに使われます。
120
+ トレイトは推論された変性を持たないため、 ` fn(T) ` は ` T ` において変性ではありません。)
113
121
114
122
Some important variances:
115
123
You can’t perform that action at this time.
0 commit comments