Hello,
I would appreciate if you could give me some hint on owning a struct from another struct. Sample code(struct definitions are skippe).
How to let 'Bar' owns 'Foo' instead of borrowing 'Foo'.
impl Foo
{
pub fn new() -> Self()
{
Foo
{
name: "",
age: 20
}
}
}
impl struct Bar
{
pub fn new() -> Self
{
Bar
{
// How to make 'bar' owns the foo instance instead of borrowing? (borrowing is not correct here obviously)
// clone and copy do not work. e.g, foo::new().clone(), foo::new().copy()
bar: foo::new(),
cookie: "cookie"
}
}
}
Another question is it possible to make a const variable using non-constant function?
pub const BIGINT_ZERO: Integer = rug::Integer::from(0);
`error[E0015]: cannot call non-const fn `<Integer as From<i32>>::from` in constants`
Thanks a lot.