Posted on :: Tags: , , ,

There are a few crates in Rust for retrieving system-dependent directories, such as the user’s home or the system configuration directory. The one I prefer is directories-next.

Recently, I needed a standard way to get the temporary directory. I checked the crate documentation but couldn’t find a proper function for this.

Then I noticed that std::env::temp_dir() returns a PathBuf pointing to the system’s temporary directory. This is a reminder to myself that we don’t always need extra packages for basic functionality.