Skip to content

Commit add408c

Browse files
committed
PEP 695: fix rust information
1 parent 943a891 commit add408c

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

pep-0695.rst

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,9 @@ Rust uses angle brackets to declare type parameters and for specialization.
10661066
The upper bound of a type parameter is specified using a colon. Alternatively
10671067
a "where" clause can specify various constraints.
10681068

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.
10721072

10731073
A default type argument can be specified using the "=" operator.
10741074

@@ -1080,7 +1080,7 @@ A default type argument can be specified using the "=" operator.
10801080
}
10811081

10821082
// Type parameter with bound
1083-
struct StructB<T: StructA> {}
1083+
struct StructB<T: SomeTrait> {}
10841084

10851085
// Type parameter with additional constraints
10861086
struct StructC<T>
@@ -1092,16 +1092,8 @@ A default type argument can be specified using the "=" operator.
10921092
// Generic function
10931093
fn func1<T>(val: &[T]) -> T { }
10941094

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-
11031095
// Generic type alias
1104-
type MyType<T> = StructC<T>
1096+
type MyType<T> = StructC<T>;
11051097

11061098

11071099
Kotlin
@@ -1210,8 +1202,8 @@ Summary
12101202
+------------+----------+---------+--------+----------+-----------+-----------+
12111203
| Swift | <> | T: X | | | n/a | n/a |
12121204
+------------+----------+---------+--------+----------+-----------+-----------+
1213-
| Rust | <> | T: X, | | = | decl | inferred, |
1214-
| | | where | | | | explicit |
1205+
| Rust | <> | T: X, | | = | n/a | n/a |
1206+
| | | where | | | | |
12151207
+------------+----------+---------+--------+----------+-----------+-----------+
12161208
| Kotlin | <> | T: X, | | | use, decl | in, out |
12171209
| | | where | | | | |

0 commit comments

Comments
 (0)