请帮我解决以下错误:
error[E0382]: use of moved value: `nd3`
--> src/main.rs:21:21
|
19 | Node::Y { nd: nd3, max: max } => {
| --- move occurs because `nd3` has type `std::boxed::Box<Node>`, which does not implement the `Copy` trait
20 | for m in 0..max - 1 {
21 | match recur(nd3) {
| ^^^ value moved here, in previous iteration of loop
以下是代码。请不要在意代码看起来毫无意义,因为我对它进行了简化:
enum Node {
X { x: usize },
Y { nd: Box<Node>, max: usize },
Z { Nd: Vec<Box<Node>> },
}
fn recur(nd: Box<Node>) -> Result<usize, ()> {
match *nd {
/// ...
Node::Y { nd: nd3, max: max } => {
for m in 0..max - 1 {
match recur(nd3) {
Ok(y) => return Ok(y),
_ => {}
}
}
return Ok(123);
}
_ => {}
}
return Ok(0);
}