Skip to main content

argv_strings

Function argv_strings 

Source
pub fn argv_strings(
    argv: impl IntoIterator<Item = OsString>,
) -> Result<Vec<String>, String>
Expand description

Convert process arguments to text, naming the first that is not UTF-8. 把进程参数转成文本,并点名第一个不是 UTF-8 的参数。

An argument on Linux may be any byte string, and std::env::args() unwraps the conversion: nichlink check "/tmp/proj\xff" died with a Rust backtrace instead of printing a usage error, which is not what a command-line tool owes a caller. Linux 上的参数可以是任意字节串,而 std::env::args() 会对转换 unwrap: nichlink check "/tmp/proj\xff" 会带着 Rust backtrace 死掉,而不是打印一条用法错误—— 这不是命令行工具该给调用方的答复。