home ~ socials ~ other projects

Get the Current Working Directory in Rust

use std::env;

fn main() -> std::io::Result<()> {
    let path = env::current_dir()?;
    println!("The current directory is {}", path.display());
    Ok(())
}
Output:
The current directory is /Users/alan/workshop/examples
-- end of line --