I have a Vec<Box<T>>
where T
implements Foo
. Why can I not coerce it to a Vec<Box<Foo>>
even though I can coerce anything of type Box<T>
into a Box<Foo>
? Why does the below code not compile?
use std::vec;
trait Foo {}
struct Bar {}
impl Foo for Bar {}
fn main() {
let v = vec![Box::new(Bar {})];
let v_1 = v as Vec<Box<Foo>>;
}