This repository was archived by the owner on Apr 5, 2024. It is now read-only.
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
Move out of reference in move closures #31
Closed
Description
struct S {
x: String,
y: String
}
fn x(s: &mut S) {
let mut c = move || {
s.x.truncate(0);
};
c();
}
fn main() {
let mut s = S { x: "".into(), y: "".into() };
x(&mut s);
}
Without the feature gate s
which is a &mut S
is moved. However with the feature gate *s.x
is moved which is a String
which behind a &mut S
and can't be moved out.