Change `FromArgs::from_args` to accept `AsRef<str>`
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
Current the function is defined as:
```rust
fn from_args(command_name: &[&str], args: &[&str]) -> Result;
```
This could be changed to:
```rust
fn from_args(command_name: &[T], args: &[U]) -> Result where T: AsRef, U: AsRef;
```
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` to `&[&str]`, which is a little sad.
1. `OsStr` to `String` (`to_string_lossy`, `to_string + unwrap`)
2. Collect to a vec of `String`
3. Iter, `as_str`
4. Collect to a vec of `&str`
With the change proposed in this issue, steps 3 and 4 would become unnecessary
Contributor guide
Assessment
This issue has not been assessed yet.