I got the following error and struggle to stop compiler complaining
Error
cannot move out of *__arg1_0 which is behind a shared reference
move occurs because *__arg1_0 has type Arc<dyn MyTrait>, which does not implement the Copy trait
What I am trying to do is that I have a pub enum with derive macro PartialEq and I want to introduce new enum value with trait, Arc<dyn MyTrait> and sadly I got error, the above code is the short version of code that also come out error.
error: lifetime may not live long enough
--> src/main.rs:21:30
|
17 | impl<'a> ::core::cmp::PartialEq for MyEnum<'a> {
| -- lifetime `'a` defined here
...
21 | (MyEnum::MyTrait(__self_0), MyEnum::MyTrait(__arg1_0)) =>
| ^^^^^^^^ assignment requires that `'a` must outlive `'static`
Just where is that assignment they are talking about?!
error[E0507]: cannot move out of `*__arg1_0` which is behind a shared reference
--> src/main.rs:22:30
|
22 | *__self_0 == *__arg1_0,
| ^^^^^^^^^ move occurs because `*__arg1_0` has type `Box<dyn MyTrait>`, which does not implement the `Copy` trait