rust/src/test/run-pass/anon-obj-degenerate.rs

25 lines
378 B
Rust
Raw Normal View History

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