mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
20 lines
323 B
Rust
20 lines
323 B
Rust
struct Foo {
|
|
foo: isize,
|
|
}
|
|
|
|
struct Bar {
|
|
bar: isize,
|
|
}
|
|
|
|
impl Bar {
|
|
fn make_foo (&self, i: isize) -> Box<Foo> {
|
|
return Box::new(Foo { nonexistent: self, foo: i }); //~ ERROR: no field named
|
|
}
|
|
}
|
|
|
|
fn main () {
|
|
let bar = Bar { bar: 1 };
|
|
let foo = bar.make_foo(2);
|
|
println!("{}", foo.foo);
|
|
}
|