2013-08-13 03:18:47 +00:00
|
|
|
struct Foo {
|
2015-01-08 10:54:35 +00:00
|
|
|
foo: isize,
|
2013-08-13 03:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar {
|
2015-01-08 10:54:35 +00:00
|
|
|
bar: isize,
|
2013-08-13 03:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Bar {
|
2015-01-08 10:54:35 +00:00
|
|
|
fn make_foo (&self, i: isize) -> Box<Foo> {
|
2022-07-07 02:36:10 +00:00
|
|
|
return Box::new(Foo { nonexistent: self, foo: i }); //~ ERROR: no field named
|
2013-08-13 03:18:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main () {
|
|
|
|
let bar = Bar { bar: 1 };
|
|
|
|
let foo = bar.make_foo(2);
|
2013-09-30 03:06:21 +00:00
|
|
|
println!("{}", foo.foo);
|
2013-08-13 03:18:47 +00:00
|
|
|
}
|