#argv #osstr #iterator #static

argv

Command line arguments by reference: Iterator<Item = &'static OsStr>

4 releases

0.1.3 Oct 7, 2020
0.1.2 Jun 16, 2020
0.1.1 Mar 22, 2020
0.1.0 Jan 13, 2019
0.0.0 Jan 13, 2019

#69 in Command-line interface

Download history 333/week @ 2021-02-25 386/week @ 2021-03-04 423/week @ 2021-03-11 581/week @ 2021-03-18 751/week @ 2021-03-25 635/week @ 2021-04-01 588/week @ 2021-04-08 501/week @ 2021-04-15 508/week @ 2021-04-22 503/week @ 2021-04-29 448/week @ 2021-05-06 399/week @ 2021-05-13 386/week @ 2021-05-20 372/week @ 2021-05-27 371/week @ 2021-06-03 218/week @ 2021-06-10

2,043 downloads per month
Used in 3 crates (via gflags)

MIT/Apache

11KB
115 lines

Command line arguments by reference

github crates.io docs.rs build status

The standard library's std::env::args_os iterator produces an owned string (OsString) for each argument. In some use cases it can be more convenient for the arguments to be produced by static reference (&'static OsStr).

[dependencies]
argv = "0.1"

Example

fn main() {
    for arg in argv::iter() {
        // arg is a &'static OsStr.
        println!("{}", arg.to_string_lossy());
    }
}

Portability

This crate is intended to be used on Linux and macOS, on which command line arguments naturally live for the duration of the program. This crate implements the same API on other platforms as well, such as Windows, but leaks memory on platforms other than Linux and macOS.


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps