Skip to content

Commit

Permalink
Use of the type in interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Havvy committed Jul 14, 2012
1 parent c5b23c3 commit 2d23669
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/tutorial.md
Expand Up @@ -2508,6 +2508,18 @@ 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

0 comments on commit 2d23669

Please sign in to comment.