Skip to content

Commit

Permalink
tutorial: Fix 'self' to 'Self'
Browse files Browse the repository at this point in the history
  • Loading branch information
ILyoan committed Apr 29, 2013
1 parent ea74f68 commit 9d33008
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2056,11 +2056,10 @@ method declarations. So, re-declaring the type parameter
`T` as an explicit type parameter for `len`, in either the trait or
the impl, would be a compile-time error.

Within a trait definition, `self` is a special type that you can think
Within a trait definition, `Self` is a special type that you can think
of as a type parameter. An implementation of the trait for any given
type `T` replaces the `self` type parameter with `T`. Simply, in a
trait, `self` is a type, and in an impl, `self` is a value. The
following trait describes types that support an equality operation:
type `T` replaces the `Self` type parameter with `T`. The following
trait describes types that support an equality operation:

~~~~
// In a trait, `self` refers to the self argument.
Expand All @@ -2076,7 +2075,7 @@ impl Eq for int {
~~~~

Notice that in the trait definition, `equals` takes a
second parameter of type `self`.
second parameter of type `Self`.
In contrast, in the `impl`, `equals` takes a second parameter of
type `int`, only using `self` as the name of the receiver.

Expand Down

1 comment on commit 9d33008

@ILyoan
Copy link
Contributor Author

@ILyoan ILyoan commented on 9d33008 Apr 29, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I've accidently commit this change without any review. (I thought it would go to pull request.. :( )

Please sign in to comment.