Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial: Added note about type parameters in ifaces. #2919

Merged
merged 2 commits into from
Jul 20, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2504,6 +2504,22 @@ needed because it could also, for example, specify an implementation
of `seq<int>`—the `of` clause *refers* to a type, rather than defining
one.

Note that functions do not explicitly have the type parameters that
are provided by the iface. It will cause a compile-time error if you
include them in the iface or impl.

## Use of the type `self` in interfaces

Interfaces may use `self` as a type where the implementation uses its
own type. This defines an interface for testing equality of a type with
itself:

~~~~
iface eq {
fn equals(other: self) -> bool;
}
~~~~

## Casting to an interface type

The above allows us to define functions that polymorphically act on
Expand Down