From 0ce88fe401e272f072a18e01bddabdea93abec51 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 6 Sep 2012 16:19:34 -0700 Subject: [PATCH] Update docs to not refer to the `of` clause in an impl Closes #3375 --- doc/rust.md | 4 ++-- doc/tutorial.md | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/doc/rust.md b/doc/rust.md index 20f25c8c2b4..d16c2a6c072 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -1309,8 +1309,8 @@ the same time. It is possible to define an implementation without referring to a trait. The methods in such an implementation can only be used statically (as direct calls on the values of the type that the -implementation targets). In such an implementation, the `of` clause is -not given, and the name is mandatory. Such implementations are +implementation targets). In such an implementation, the type after the colon is omitted, +and the name is mandatory. Such implementations are limited to nominal types (enums, structs) and the implementation must appear in the same module or a sub-module as the receiver type. diff --git a/doc/tutorial.md b/doc/tutorial.md index dd1f6b66f45..cdd6f56ead0 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1951,8 +1951,8 @@ whose element type does not have a `to_str` implementation in scope. ## Polymorphic traits -Traits may contain type parameters. This defines a trait for -generalized sequence types: +Traits may contain type parameters. A trait for +generalized sequence types is: ~~~~ trait seq { @@ -1967,11 +1967,8 @@ impl ~[T]: seq { } ~~~~ -Note that the implementation has to explicitly declare the type -parameter that it binds, `T`, before using it to specify its trait type. This is -needed because it could also, for example, specify an implementation -of `seq`—the `of` clause *refers* to a type, rather than defining -one. +The implementation has to explicitly declare the type +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`. The trait type -- appearing after the colon in the `impl` -- *refers* to a type, rather than defining one. The type parameters bound by a trait are in scope in each of the method declarations. So, re-declaring the type parameter @@ -2066,7 +2063,7 @@ more expensive than statically resolved method calls. If you only intend to use an implementation for static overloading, and there is no trait available that it conforms to, you are free -to leave off the `of` clause. However, this is only possible when you +to leave off the type after the colon. However, this is only possible when you are defining an implementation in the same module as the receiver type, and the receiver type is a named type (i.e., an enum or a class); [single-variant enums](#single_variant_enum) are a common