Hello,
Can I move a value to a different field without cloning it, if I overwrite the original one? Consider:
struct TwoValues {
previous: String,
current: String
}
impl TwoValues {
fn push(&mut self, next: String) -> () {
self.previous = self.current.clone(); // Can I get rid of this clone?
self.current = next;
}
}
This won't compile without the clone()
, because it would move a filed. Can I get rid of the clone by replacing the value in the same step? Thanks!
Best, Oliver