From c5b23c3400e039e408a40f633bfae8aa39a17c20 Mon Sep 17 00:00:00 2001 From: Ryan Scheel Date: Sat, 14 Jul 2012 01:36:42 -0700 Subject: [PATCH 1/2] Added note about type parameters in ifaces. Specficially, the type parameters should be left off of the function signatures in both the iface and the impl if they are already in the iface declaration. --- doc/tutorial.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/tutorial.md b/doc/tutorial.md index f1b6b8ce863fd..45890caef88ae 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2504,6 +2504,10 @@ needed because it could also, for example, specify an implementation of `seq`—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. + ## Casting to an interface type The above allows us to define functions that polymorphically act on From 2d236695aa5726525ef7320bdbaa418f23d0aff9 Mon Sep 17 00:00:00 2001 From: Ryan Scheel Date: Sat, 14 Jul 2012 16:17:22 -0700 Subject: [PATCH 2/2] Use of the type in interfaces --- doc/tutorial.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/tutorial.md b/doc/tutorial.md index 45890caef88ae..e481e4daf0217 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -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