You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/tutorial.md
+5-8Lines changed: 5 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1951,8 +1951,8 @@ whose element type does not have a `to_str` implementation in scope.
1951
1951
1952
1952
## Polymorphic traits
1953
1953
1954
-
Traits may contain type parameters. This defines a trait for
1955
-
generalized sequence types:
1954
+
Traits may contain type parameters. A trait for
1955
+
generalized sequence types is:
1956
1956
1957
1957
~~~~
1958
1958
trait seq<T> {
@@ -1967,11 +1967,8 @@ impl<T> ~[T]: seq<T> {
1967
1967
}
1968
1968
~~~~
1969
1969
1970
-
Note that the implementation has to explicitly declare the type
1971
-
parameter that it binds, `T`, before using it to specify its trait type. This is
1972
-
needed because it could also, for example, specify an implementation
1973
-
of `seq<int>`—the `of` clause *refers* to a type, rather than defining
1974
-
one.
1970
+
The implementation has to explicitly declare the type
1971
+
parameter that it binds, `T`, before using it to specify its trait type. Rust requires this declaration because the `impl` could also, for example, specify an implementation of `seq<int>`. The trait type -- appearing after the colon in the `impl` -- *refers* to a type, rather than defining one.
1975
1972
1976
1973
The type parameters bound by a trait are in scope in each of the
1977
1974
method declarations. So, re-declaring the type parameter
@@ -2066,7 +2063,7 @@ more expensive than statically resolved method calls.
2066
2063
2067
2064
If you only intend to use an implementation for static overloading,
2068
2065
and there is no trait available that it conforms to, you are free
2069
-
to leave off the `of` clause. However, this is only possible when you
2066
+
to leave off the type after the colon. However, this is only possible when you
2070
2067
are defining an implementation in the same module as the receiver
2071
2068
type, and the receiver type is a named type (i.e., an enum or a
2072
2069
class); [single-variant enums](#single_variant_enum) are a common
0 commit comments