Skip to content

Commit d172cf5

Browse files
committed
---
yaml --- r: 20527 b: refs/heads/snap-stage3 c: ac9cf98 h: refs/heads/master i: 20525: 0e635fe 20523: 900f80a 20519: ea63633 20511: 09c86b5 v: v3
1 parent 913ced8 commit d172cf5

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 0f34144be308d28260d2496104ad06c2cb9cf5c3
4+
refs/heads/snap-stage3: ac9cf98564cc394672cd9a96a02093569951027c
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/tutorial.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,22 +2504,33 @@ needed because it could also, for example, specify an implementation
25042504
of `seq<int>`—the `of` clause *refers* to a type, rather than defining
25052505
one.
25062506

2507-
Note that functions do not explicitly have the type parameters that
2508-
are provided by the iface. It will cause a compile-time error if you
2509-
include them in the iface or impl.
2507+
The type parameters bound by an iface are in scope in each of the
2508+
method declarations. So, re-declaring the type parameter
2509+
`T` as an explicit type parameter for `len` -- in either the iface or
2510+
the impl -- would be a compile-time error.
25102511

2511-
## Use of the type `self` in interfaces
2512+
## The `self` type in interfaces
25122513

2513-
Interfaces may use `self` as a type where the implementation uses its
2514-
own type. This defines an interface for testing equality of a type with
2515-
itself:
2514+
In an interface, `self` is a special type that you can think of as a
2515+
type parameter. An implementation of the interface for any given type
2516+
`T` replaces the `self` type parameter with `T`. The following
2517+
interface describes types that support an equality operation:
25162518

25172519
~~~~
25182520
iface eq {
25192521
fn equals(other: self) -> bool;
25202522
}
25212523
~~~~
25222524

2525+
In an implementation for type `int`, the `equals` method takes an
2526+
`int` argument:
2527+
2528+
~~~~
2529+
impl of eq for int {
2530+
fn equals(other: int) { other == self }
2531+
}
2532+
~~~~
2533+
25232534
## Casting to an interface type
25242535

25252536
The above allows us to define functions that polymorphically act on

0 commit comments

Comments
 (0)