I reduced my problem to the following code:
enum E {
E1,
}
fn f(e1: &E, e2: &E) {
match *e1 {
E::E1 => (),
}
match (*e1, *e2) {
(E::E1, E::E1) => (),
}
}
fn main() {}
The first match is ok, but the second fails to compile:
error[E0507]: cannot move out of borrowed content
--> src/main.rs:9:12
|
9 | match (*e1, *e2) {
| ^^^ cannot move out of borrowed content
error[E0507]: cannot move out of borrowed content
--> src/main.rs:9:17
|
9 | match (*e1, *e2) {
| ^^^ cannot move out of borrowed content
It seems that this is because I'm constructing a pair of something borrowed and Rust tries to move e1
and e2
into it. I found out that if I put "#[derive(Copy, Clone)]" before my enum, my code compiles.