std-type
OsStr: borrowed native string
Represent borrowed native strings without assuming UTF-8. Keep native strings for file operations and convert only when needed. Expected stdout (not executed): گزارش Common mistake: Assuming every operating-system string is Unicode text.
Formal Syntax & Structure
rust syntaxrust
OsStr::new(s); os.to_str() -> Option<&str>Working Example
Example Snippetrust
fn main() { use std::ffi::OsStr; let name = OsStr::new("گزارش"); println!("{}", name.to_str().unwrap());}