How to Check if a File or Directory Exists in Rust

Check if a file or directory exists in Rust using the Path::exists() method.

Use std::path::Path::exists() to check if a file or directory exists at a given path.

use std::path::Path;

fn main() {
    let path = Path::new("/home/sd/crewai/src/rust/book");
    if path.exists() {
        println!("Path exists");
    } else {
        println!("Path does not exist");
    }
}