Hello,
I'm learning rust and trying to understand why rust allows me to compile
this piece of code. When Drop impl is uncommented - rustc complains about
'use of moved value', which is ok i think. My question is - why it compiles
code when Drop is not implemented for Inner struct? If its behaves as
intended - where i can read about this difference?
struct Inner;
impl Inner {
fn innerFn(&mut self) {
println!("Inner::innerFn"); // just for tracing
}
}
struct Outer {
i: Inner
}
// uncomment it, and we get error: use of moved value: `inner`
/*
impl Drop for Inner {
fn drop(&mut self) {
println!("Inner::drop"); // just for tracing
}
}
*/
fn main() {
let mut inner = Inner;
let mut outer = Outer { i: inner }; // inner is moved into outer.i ?
inner.innerFn(); // why then i can call its method?
outer.i.innerFn();
}
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev