I'm trying to implement the following:
struct Foo {
x: Vec<String>,
}
impl<V: Into<Vec<S>>, S: Into<String>> From<V> for Foo {
fn from(x: V) -> Self {
Self { x: x.into() }
}
}
But I get the following error message:
error[E0207]: the type parameter `S` is not constrained by the impl trait, self type, or predicates
--> src/main.rs:5:23
|
5 | impl<V: Into<Vec<S>>, S: Into<String>> From<V> for Foo {
| ^ unconstrained type parameter
After reading E0207
, it seems, this is not possible – is that correct?
If so: is there another way to archive this? I'm trying to avoid type parameters on Foo
.
Basically, I'd like to be able to use Foo { x: ["bar"] }
, etc.