Hi,
I was trying the following today (with nightly, specialisation turned on):
impl<Y: From<X>, X> From<Option<X>> for Option<Y> {
fn from(self: Option<X>) {
match self {
Some(x) => Some(x.from()),
None => None
}
}
}
This fails, because there is already a blanket implementation of From<T> for T. I was assuming specialization would solve such cases, but it seems not.
Intuitively, I would say that Option<T> is more specialized then T, but this doesn’t seem to be the case. Curiously though, I have found no mention of these cases in the relevant RFC, nor can I come up with a reason why this would be a problem. I could be wrong though, just because I haven’t found a problematic example doesn’t mean there isn’t one :).
Can someone shed some light in here for me?
(playpen)