Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

ChangeFromArgs::from_args to acceptAsRef<str> #160

Open
@poliorcetics

Description

@poliorcetics

Current the function is defined as:

fnfrom_args(command_name:&[&str],args:&[&str]) ->Result<Self,EarlyExit>;

This could be changed to:

fnfrom_args<T,U>(command_name:&[T],args:&[U]) ->Result<Self,EarlyExit>whereT: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 fromstd::env::args_os(), severalcollects and transformations are necessary to go fromIterator<Item = OsStr> to&[&str], which is a little sad.

  1. OsStr toString (to_string_lossy,to_string + unwrap)
  2. Collect to a vec ofString
  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp