Why can't I cast a Box with an extended trait to a Box with the base trait? [duplicate]
问题 This question already has answers here : Why doesn't Rust support trait object upcasting? (3 answers) Closed 2 years ago . Given the code trait Base { } trait Derived : Base { } struct Foo { } impl Base for Foo { } impl Derived for Foo { } fn main() { let b : Box<Derived> = Box::new( Foo { } ); let a : Box<Base> = b; } When I compile as I'm sure you know I get the following error message: error[E0308]: mismatched types --> src/main.rs:14:25 | 14 | let a : Box<Base> = b; | ^ expected trait