Closed
Description
Consider this example:
struct Test(u64, u64);
impl Test {
fn into_tuple(self) -> (u64, u64) {
(self.0, self.1)
}
}
fn main() {
let x = vec![Test(1,1), Test(1,2)];
let _tuples = x.iter().map(|test| test.clone().into_tuple()).collect::<Vec<_>>();
}
struct Test
is not implementing Clone
trait, but here is the error message:
Compiling playground v0.0.1 (file:///playground)
error[E0507]: cannot move out of borrowed content
--> src/main.rs:12:39
|
12 | let _tuples = x.iter().map(|test| test.clone().into_tuple()).collect::<Vec<_>>();
| ^^^^^^^^^^^^ cannot move out of borrowed content
error: aborting due to previous error