What is OsStr and OsString

OsStr and OsString are Rust types for handling file paths and arguments that may contain invalid Unicode, preventing panics.

OsStr and OsString are platform-agnostic types for representing file system paths and command-line arguments that may contain invalid Unicode. Use std::env::args_os() to retrieve arguments as OsString values instead of std::env::args() to avoid panics on invalid input.

use std::env;

fn main() {
    let args: Vec<OsString> = env::args_os().collect();
    for arg in args {
        println!("{:?}", arg);
    }
}