How to Handle Platform-Specific File Paths in Rust

Use std::path::PathBuf and std::env::args_os to handle file paths portably across Windows, Linux, and macOS in Rust.

Use std::path::PathBuf to store file paths and std::env::args_os to read command-line arguments as platform-agnostic OsString values. This approach avoids manual string manipulation for separators and handles invalid Unicode gracefully.

use std::env;
use std::path::PathBuf;

fn main() {
    let args: Vec<PathBuf> = env::args_os().skip(1).collect();
    let file_path = args.first().expect("No file path provided");
    println!("Path: {:?}", file_path);
}