I'm using crate structopt. I want to implement a parameter which has a list of elements.
I've tried to implement it in the following way:
struct Foo(Vec<String>);
impl FromStr for Foo {
type Err = Utf8Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(s.split(",").map(|s| s.to_string()).collect())
}
}
But Rust complains with following error message:
error[E0277]: a value of type `options::Foo` cannot be built from an iterator over elements of type `std::string::String`
--> zarlib/src/options.rs:15:12
|
15 | Ok(s.split(",").map(|s| s.to_string()).collect())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value of type `options::Foo` cannot be built from `std::iter::Iterator<Item=std::string::String>`
|
= help: the trait `std::iter::FromIterator<std::string::String>` is not implemented for `options::Foo`
How do I solve this?