Hello there! I'm using the clap library to parse command line arguments. Among others, I have an argument t
which can be a list of values. Supposing my binary is called "bin", then an example call is bin -t foo bar
with the values of -t
being the list [foo, bar]
.
I'm representing such argument as a Option<Vec<String>>
and I do initialize it as following:
let tags: Option<Vec<String>> = match arguments.values_of("tag") {
Some(values) => Some(values.map(|s| s.to_string()).collect()),
None => None
};
where arguments
is the clap App struct. My question is: is this an idiomatic way to set up an Option value? For example, I don't really like the fact that I'm repeating Some/Some and None/None in the respective branches.