I think, when I make a ref to dereferenced object, I do nothing. But I have a code:
fn push_f32(dst: &mut Vec<f32>, value: f32, eps: f32) {
for v in &mut *dst { // <----- here!!!!
if (*v - value).abs() < eps {
return;
}
}
dst.push(value);
}
If I make just
for v in dst {
in second line, I see this error:
Compiling axis_drawer v0.1.0 (D:\RustProj\axis_drawer)
error[E0382]: borrow of moved value: `dst`
--> src\solver.rs:376:29
|
369 | fn push_f32(dst: &mut Vec<f32>, value: f32, eps: f32) {
| --- move occurs because `dst` has type `&mut Vec<f32>`, which does not implement the `Copy` trait
370 | for v in dst {
| --- `dst` moved due to this implicit call to `.into_iter()`
...
376 | dst.push(value);
| ^^^^^^^^^^^^^^^ value borrowed here after move
|
note: `into_iter` takes ownership of the receiver `self`, which moves `dst`
--> C:\Users\user\.rustup\toolchains\stable-i686-pc-windows-gnu\lib/rustlib/src/rust\library\core\src\iter\traits\collect.rs:262:18
|
262 | fn into_iter(self) -> Self::IntoIter;
| ^^^^
help: consider creating a fresh reborrow of `dst` here
|
370 | for v in &mut *dst {
| ++++++
It looks inconsistent