@@ -1066,9 +1066,9 @@ Rust uses angle brackets to declare type parameters and for specialization.
1066
1066
The upper bound of a type parameter is specified using a colon. Alternatively
1067
1067
a "where" clause can specify various constraints.
1068
1068
1069
- Rust uses declaration-site variance, and variance of type parameters is
1070
- typically inferred from their usage. In cases where a type parameter is not
1071
- used within a type, variance can be specified explicitly .
1069
+ Rust does not have traditional object oriented inheritance or variance.
1070
+ Subtyping in Rust is very restricted and occurs only due to variance with
1071
+ respect to lifetimes .
1072
1072
1073
1073
A default type argument can be specified using the "=" operator.
1074
1074
@@ -1092,14 +1092,6 @@ A default type argument can be specified using the "=" operator.
1092
1092
// Generic function
1093
1093
fn func1<T>(val: &[T]) -> T { }
1094
1094
1095
- // Explicit variance specification
1096
- use type_variance::{Covariant, Contravariant};
1097
-
1098
- struct StructD<A, R> {
1099
- arg: Covariant<A>,
1100
- ret: Contravariant<R>,
1101
- }
1102
-
1103
1095
// Generic type alias
1104
1096
type MyType<T> = StructC<T>
1105
1097
@@ -1210,8 +1202,7 @@ Summary
1210
1202
+------------+----------+---------+--------+----------+-----------+-----------+
1211
1203
| Swift | <> | T: X | | | n/a | n/a |
1212
1204
+------------+----------+---------+--------+----------+-----------+-----------+
1213
- | Rust | <> | T: X, | | = | decl | inferred, |
1214
- | | | where | | | | explicit |
1205
+ | Rust | <> | T: X, | | = | n/a | n/a |
1215
1206
+------------+----------+---------+--------+----------+-----------+-----------+
1216
1207
| Kotlin | <> | T: X, | | | use, decl | in, out |
1217
1208
| | | where | | | | |
0 commit comments