I have a vector of a specific type. I can create a From trait that automatically converts a &str into the type.
impl From<&str> for Type {
fn from(value: &str) -> Self {
Self { value: value.to_string() }
}
}
I want to have a From
trait implementation that allows me to automatically convert a Vec
of &str
's to a Vec
of these types. I tried something like this:
impl From<Vec<&str>> for Vec<Type> {
fn from(value: Vec<&str>) -> Self {
Self { value: todo!() }
}
}
This does not compile because I cannot implement an external trait on an external type. Is there any other elegant way to accomplish this?