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