Crates.io | argv |
lib.rs | argv |
version | 0.1.11 |
source | src |
created_at | 2019-01-13 01:41:33.503501 |
updated_at | 2024-01-10 02:45:01.633408 |
description | Command line arguments by reference: `Iterator |
homepage | |
repository | https://github.com/dtolnay/argv |
max_upload_size | |
id | 108261 |
size | 23,591 |
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"
fn main() {
for arg in argv::iter() {
// arg is a &'static OsStr.
println!("{}", arg.to_string_lossy());
}
}
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.