fn modify_args<I: IntoIterator<Item = T>, T: Into<OsString> + Clone>(
    args: I,
) -> impl IntoIterator<Item = OsString> {
    let mut args = args.into_iter().map(Into::into).collect::<Vec<_>>();

    if args.len() >= 2 {
        let program: &OsStr = args[0].as_os_str();
        let program = program.to_string_lossy();

        // when `cargo-msrv(.exe)` or `msrv` are present
        if program.ends_with("cargo-msrv") || program.ends_with("cargo-msrv.exe") {
            // remove `msrv`, or `cargo-msrv(.exe)`
            args[0] = OsStr::new("cargo").to_os_string();

            let cargo_msrv_subcmd: &OsStr = args[1].as_os_str();
            let cargo_msrv_subcmd = cargo_msrv_subcmd.to_string_lossy();

            if cargo_msrv_subcmd != "msrv" {
                args.insert(1, OsStr::new("msrv").to_os_string());
            }
        }
    }

    args
}
// When we call cargo-msrv with cargo, cargo will supply the msrv subcommand, in addition
// to the binary name itself. As a result, when you call cargo-msrv without cargo, for example
// `cargo-msrv` (without cargo) instead of `cargo msrv` (with cargo), the process will receive
// too many arguments, and you will have to specify the subcommand again like so: `cargo-msrv msrv`.
// This function removes the subcommand when it's present in addition to the program name.
When we call cargo-msrv with cargo, cargo will supply the msrv subcommand, in addition
to the binary name itself.
When we call cargo - msrv with cargo cargo will supply the msrv subcommand in addition to the binary name itself .
fn modify_args<I: IntoIterator<Item = T>, T: Into<OsString> + Clone>(
    args: I,
) -> impl IntoIterator<Item = OsString> {
    let mut args = args.into_iter().map(Into::into).collect::<Vec<_>>();
    if args.len() >= 2 {
        let program: &OsStr = args[0].as_os_str();
        let program = program.to_string_lossy();
        // when `cargo-msrv(.exe)` or `msrv` are present
        if program.ends_with("cargo-msrv") || program.ends_with("cargo-msrv.exe") {
            // remove `msrv`, or `cargo-msrv(.exe)`
            args[0] = OsStr::new("cargo").to_os_string();
            let cargo_msrv_subcmd: &OsStr = args[1].as_os_str();
            let cargo_msrv_subcmd = cargo_msrv_subcmd.to_string_lossy();
            if cargo_msrv_subcmd != "msrv" {
                args.insert(1, OsStr::new("msrv").to_os_string());
            }
        }
    }
    args
}
fn modify_args < I : IntoIterator < Item = T > , T : Into < OsString > + Clone > ( args : I , ) -> impl IntoIterator < Item = OsString > { let mut args = args . into_iter ( ) . map ( Into :: into ) . collect :: < Vec < _ > > ( ) ; if args . len ( ) >= 2 { let program : & OsStr = args [ 0 ] . as_os_str ( ) ; let program = program . to_string_lossy ( ) ; // when `cargo-msrv(.exe)` or `msrv` are present if program . ends_with ( " " ) || program . ends_with ( " " ) { // remove `msrv`, or `cargo-msrv(.exe)` args [ 0 ] = OsStr :: new ( " " ) . to_os_string ( ) ; let cargo_msrv_subcmd : & OsStr = args [ 1 ] . as_os_str ( ) ; let cargo_msrv_subcmd = cargo_msrv_subcmd . to_string_lossy ( ) ; if cargo_msrv_subcmd != " " { args . insert ( 1 , OsStr :: new ( " " ) . to_os_string ( ) ) ; } } } args }
When we call cargo-msrv with cargo, cargo will supply the msrv subcommand, in addition
to the binary name itself.
When we call cargo - msrv with cargo cargo will supply the msrv subcommand in addition to the binary name itself .
args
I
args
I