#command-line-arguments #reference #osstr #iterator #static #args

argv

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

12 releases

0.1.11 Jan 10, 2024
0.1.10 Dec 21, 2023
0.1.9 Jul 15, 2023
0.1.8 Mar 3, 2023
0.1.0 Jan 13, 2019

#130 in Command-line interface

Download history 1132/week @ 2023-12-23 2079/week @ 2023-12-30 2810/week @ 2024-01-06 3004/week @ 2024-01-13 3138/week @ 2024-01-20 1685/week @ 2024-01-27 814/week @ 2024-02-03 1017/week @ 2024-02-10 1107/week @ 2024-02-17 1093/week @ 2024-02-24 1007/week @ 2024-03-02 811/week @ 2024-03-09 476/week @ 2024-03-16 330/week @ 2024-03-23 435/week @ 2024-03-30 428/week @ 2024-04-06

1,735 downloads per month
Used in 7 crates (5 directly)

MIT/Apache

10KB
114 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