Hi,
Suppose I've a struct
struct Foo {
bar: Bar,
xyz: Xyz,
}
where Bar
and Xyz
are other potentially large structs.
Suppose I'm trying to do the following:
impl Foo {
fn example(&self) {
let Foo { bar, .. } = self.clone();
// .. Do something that consumes bar
}
}
What that cause more memory than if I do these instead
impl Foo {
fn example(&self) {
let bar = self.bar.clone();
// .. Do something that consumes bar
}
}
If there's optimization that only clones the used fields, is such optimization reliably applied in every such usages?
Thanks