argh
argh copied to clipboard
Change `FromArgs::from_args` to accept `AsRef<str>`
Current the function is defined as:
fn from_args(command_name: &[&str], args: &[&str]) -> Result<Self, EarlyExit>;
This could be changed to:
fn from_args<T, U>(command_name: &[T], args: &[U]) -> Result<Self, EarlyExit> where T: AsRef<str>, U: AsRef<str>;
I think this is backward-incompatible because of type deductions that could now fail.
FromArgs::redact_arg_values
should also be updated if this is done.
Why ?
Current when getting arguments from std::env::args_os()
, several collect
s and transformations are necessary to go from Iterator<Item = OsStr>
to &[&str]
, which is a little sad.
-
OsStr
toString
(to_string_lossy
,to_string + unwrap
) - Collect to a vec of
String
- Iter,
as_str
- Collect to a vec of
&str
With the change proposed in this issue, steps 3 and 4 would become unnecessary