diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-01-29 11:14:53 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-01-29 11:48:21 -0800 |
| commit | 4ead38bae7ed244f5df9e71ebd1f739d5de0feb7 (patch) | |
| tree | 5a1423be681f5d028bf9b95ad910cb2fea68c271 /src/test/run-pass/new-impl-syntax.rs | |
| parent | 1b021d5868411341b969bfb684c7f1892cb7e092 (diff) | |
libsyntax: Implement the `impl Trait for Type` syntax
Diffstat (limited to 'src/test/run-pass/new-impl-syntax.rs')
| -rw-r--r-- | src/test/run-pass/new-impl-syntax.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/run-pass/new-impl-syntax.rs b/src/test/run-pass/new-impl-syntax.rs new file mode 100644 index 00000000000..4cb30ffa213 --- /dev/null +++ b/src/test/run-pass/new-impl-syntax.rs @@ -0,0 +1,26 @@ +struct Thingy { + x: int, + y: int +} + +impl ToStr for Thingy { + pure fn to_str() -> ~str { + fmt!("{ x: %d, y: %d }", self.x, self.y) + } +} + +struct PolymorphicThingy<T> { + x: T +} + +impl<T:ToStr> ToStr for PolymorphicThingy<T> { + pure fn to_str() -> ~str { + self.x.to_str() + } +} + +fn main() { + io::println(Thingy { x: 1, y: 2 }.to_str()); + io::println(PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_str()); +} + |
