我有以下代码(您可以try it on play.rust-lang.org):
pub enum InnerStream {
Root,
Transaction {
v: Vec<u32>,
parent: Box<InnerStream>,
},
}
impl InnerStream {
pub fn rollback(self) -> InnerStream {
match self {
InnerStream::Transaction { v: _v, parent } => match *parent {
InnerStream::Root => InnerStream::Root,
InnerStream::Transaction {
v,
parent: parent_parent,
} => InnerStream::Transaction {
v,
parent: parent_parent,
},
},
InnerStream::Root { .. } => panic!("Cannot rollback root stream."),
}
}
}
fn main() {}
(这是一个示例,不是真实的示例,请不要担心它似乎没有用)
对我来说很好,但是借位检查器给我以下错误:
error[E0382]: use of collaterally moved value: `(parent as InnerStream::Transaction).parent`
--> src/main.rs:16:29
|
15 | v,
| - value moved here
16 | parent: parent_parent,
| ^^^^^^^^^^^^^ value used here after move
|
= note: move occurs because the value has type `std::vec::Vec<u32>`, which does not implement the `Copy` trait
此错误的原因是什么,我该如何解决?