rust/src/test/run-pass/anon-obj-degenerate.rs
Brian Anderson 518dc52f85 Reformat
This changes the indexing syntax from .() to [], the vector syntax from ~[] to
[] and the extension syntax from #fmt() to #fmt[]
2011-08-20 11:04:00 -07:00

21 lines
337 B
Rust

use std;
fn main() {
obj a() {
fn foo() -> int { ret 2; }
fn bar() -> int { ret self.foo(); }
}
let my_a = a();
// Degenerate anonymous object: one that doesn't add any new
// methods or fields.
let my_d = obj () { with my_a };
assert (my_d.foo() == 2);
assert (my_d.bar() == 2);
}