Closed jmwample closed 7 months ago
use std::convert::From;
// Not possible when using type alias -- maybe consider newtype pattern
// https://stackoverflow.com/questions/25413201/how-do-i-implement-a-trait-i-dont-own-for-a-type-i-dont-own
// https://doc.rust-lang.org/stable/book/ch19-03-advanced-traits.html#using-the-newtype-pattern-to-implement-external-traits-on-external-types
impl From<HashMap<&str, Vec<&str>>> for Args {
fn from(str_map: HashMap<&str, Vec<&str>>) -> Self {
str_map
.iter()
.map(|(k, vs)| (k.to_string(), vs.iter().map(|v| v.to_string()).collect()))
.collect()
}
}
Currently Args and Opts use Strings. This is pretty inconvenient to declare and use in tests. It would be nice to have an implmenetation of
From<Hashmap<&str, Vec<&str>>>
for Args and an equivalent for Opts.This is not possible for type aliases which both Opts and Args currently are. This issue should be used to consider transitioning these types to the newtype pattern to allow implementations for non-local traits.