How to Use std

:path for Path Manipulation

Use std::path::Path for viewing paths and PathBuf for building or modifying them in a cross-platform way.

Use std::path::Path and std::path::PathBuf to handle file system paths in a platform-independent way. Path is an immutable view of a path, while PathBuf is an owned, mutable buffer that can be modified.

use std::path::{Path, PathBuf};

fn main() {
    let path = Path::new("/home/user/docs");
    let mut path_buf = PathBuf::from("/home/user");
    
    path_buf.push("docs");
    println!("Joined path: {}", path_buf.display());
    println!("File name: {}", path.file_name().unwrap().to_string_lossy());
}