2011-06-16 19:33:31 -05:00
|
|
|
use std;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
|
|
|
obj a() {
|
2011-07-27 07:19:39 -05:00
|
|
|
fn foo() -> int { ret 2; }
|
|
|
|
fn bar() -> int { ret self.foo(); }
|
2011-06-16 19:33:31 -05:00
|
|
|
}
|
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
let my_a = a();
|
2011-06-16 19:33:31 -05:00
|
|
|
|
|
|
|
// Degenerate anonymous object: one that doesn't add any new
|
2011-07-06 20:25:51 -05:00
|
|
|
// methods or fields.
|
2011-06-21 18:32:27 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
let my_d = obj () { with my_a };
|
2011-06-16 19:33:31 -05:00
|
|
|
|
|
|
|
assert (my_d.foo() == 2);
|
|
|
|
assert (my_d.bar() == 2);
|
|
|
|
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|