I meet a problem about enum, code as follows
#[derive(Debug, Clone)]
struct Mat {
d: Vec<Vec<f64>>,
row: usize,
col: usize,
}
struct Vector(Vec<f64>);
enum CompoundType {
...
Matrix(Mat),
...
}
impl From <CompoundType> for Vec<Vector> {
fn from(t: CompoundType)-> Self {
if let CompoundType::Matrix(m) = t {
return m.into_iter().map(|v| Vector::new(v)).collect();
} else {
...
}
}
}
compile error
error[E0507]: cannot move out of dereference of `toolkit::Mat`
--> src\toolkit.rs:468:20
468 | return m.into_iter().map(|v| Vector::new(v)).collect();
| ^ move occurs because value has type `Vec<Vec<f64>>`, which does not implement the `Copy` trait
In more general case, how can I take out the variable included in the enum type since I will consume this enum.
please help, thanks.