Skip to content

Commit e4a3b9a

Browse files
committed
tutorial: Fill out bounded type test case
1 parent b95a4da commit e4a3b9a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/tutorial.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,10 +2507,15 @@ values of *an* unknown type that conforms to a given interface.
25072507
However, consider this function:
25082508
25092509
~~~~
2510+
# type circle = int; type rectangle = int;
25102511
# iface drawable { fn draw(); }
2512+
# impl of drawable for int { fn draw() {} }
2513+
# fn new_circle() -> int { 1 }
25112514
fn draw_all<T: drawable>(shapes: ~[T]) {
25122515
for shapes.each |shape| { shape.draw(); }
25132516
}
2517+
# let c: circle = new_circle();
2518+
# draw_all(~[c]);
25142519
~~~~
25152520
25162521
You can call that on an array of circles, or an array of squares

0 commit comments

Comments
 (0)