Tell me this is a joke.
Tell me this is a joke.
> The returned iterator will panic during iteration if any argument to the process is not valid Unicode. If this is not desired, use the args_os function instead.
std::env::args_os encodes paths as an OsString, which is allowed to contain invalid Unicode. You can then perform your own Unicode validation as needed, instead of the "ASAP" behavior of std::env::args.
Frankly I think the onus should be on operating systems to get with the program and be UTF-8 everywhere (I think UCS-2 on Windows and "bag of bytes" filenames on Linux are braindead), but until that happens we at least have std::env::args_os as an escape hatch.
args_os is not an escape hatch, it's a pre-requisite to writing a command line argument parser. Honestly, I think the default args iterator should be deprecated, its functionality can be trivially rebuilt from args_os with the panic becoming more explicit.