We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b95a4da commit e4a3b9aCopy full SHA for e4a3b9a
doc/tutorial.md
@@ -2507,10 +2507,15 @@ values of *an* unknown type that conforms to a given interface.
2507
However, consider this function:
2508
2509
~~~~
2510
+# type circle = int; type rectangle = int;
2511
# iface drawable { fn draw(); }
2512
+# impl of drawable for int { fn draw() {} }
2513
+# fn new_circle() -> int { 1 }
2514
fn draw_all<T: drawable>(shapes: ~[T]) {
2515
for shapes.each |shape| { shape.draw(); }
2516
}
2517
+# let c: circle = new_circle();
2518
+# draw_all(~[c]);
2519
2520
2521
You can call that on an array of circles, or an array of squares
0 commit comments