I have an enumeration in Rust that has one value that String takes. This can be demonstrated with this simple example:
#[derive(Clone, Copy)] enum Simple { Error(String), Okay, Foo([u32; 5]), } fn main() { let x = Simple::Error(String::from("blah")); let y = x.clone(); }
The Foo enumeration value above represents about 10 other enumerations I use that take types or arrays to copy them. The compiler does not seem to complain about them, but only calls Error(String) :
error: the trait `Copy` may not be implemented for this type; variant `Error` does not implement `Copy` [E0205] #[derive(Clone, Copy)] ^~~~ note: in this expansion of #[derive_Copy] (defined in src\main.rs) help: run `rustc --explain E0205` to see a detailed explanation
For some reason, String not copied. I do not understand this. How to implement Clone to enumerate for only one type that has a problem when using the default value for the rest?
source share