Hi, I want to this be possible in Rust:
let x: Box<Fn(u32) -> u32> = (|x|x).into();
and I came up with this idea:
impl<U: ?Sized, T: Unsize<U>>From<T> for Box<U> {
fn from(val: T) -> Box<U> {
Box::new(val) as Box<U>
}
}
it works, but conflicts with this:
impl<T> From<T> for T {
fn from(val: T) -> T { t }
}
and (especially) with this:
impl<T> From<T> for Box<T> {
fn from(val: T) -> Box<T> { Box::new(t) }
}
it is clear why, but is any workarounds (maybe some other unstable features) for this?