Hello dear Rustlang people,
I wanted to write something along the lines of
enum What {
Nothing(i32),
}
impl <'a, T: Into<&'a str>>From<&'a T> for What {
fn from(s: &T) -> Self {
Self::Nothing(str::parse::<i32>(s.into()).unwrap())
}
}
So, I want to use From
on anything that can be converted into a &str
. Is it possible? Does it make sense? It's entirely possible that it doesn't.
Currently, the error message this gives is the trait
std::convert::From<&T> is not implemented for &str
.