In Rust, why is this correct:
trait T {}
struct S;
impl T for S {}
let a = Box::new(S{});
let b: Box<dyn T> = a;
but this isn't:
let c = Some(Box::new(S{}));
let d: Option<Box<dyn T>> = c;
this isn't:
let e: Option<Box<dyn T>> = c.map(|x| x);
but then this is:
let d: Option<Box<dyn T>> = c.map(|x| x as _);
?
I'm trying to understand which language/compiler features dictate this behavior, and, especially, why adding as _
without any type changes it.