Cloning "anyhow::Error"

I think there’s a much more specific reason. Many errors (including io::Error) store a type-erased variant:

Box<dyn error::Error + Send + Sync>

Rust just doesn’t allow such dyn objects to be Clone or Eq in a nice way. Even if you add Clone and Eq to the Error’s super-traits, this won’t just extend to a trait object, you’ll have to do some extra dancing, like here:

5 Likes