struct FooInfo<'a> {
name: &'a str,
n: i32
}
struct Foo<'a> {
name: &'a str,
n: i32
}
impl<'a> Foo<'a> {
fn new<'b>(info: &'b FooInfo<'a>) -> Foo<'a> {
Foo {
name: info.name,
n: info.n
}
}
fn print(&self) {
println!("name: {}, n: {}", self.name, self.n);
}
}
fn main() {
let s = String::from("123");
let info = FooInfo { name: &s, n: 0 };
let foo = Foo::new(&info);
drop(info);
foo.print();
}
Why is not the auxiliary structure usually used?