use once_cell::sync::Lazy; use std::{env::temp_dir, io::Result, path::PathBuf}; use tempfile::tempdir_in; pub use tempfile::TempDir; // smoelius: macOS requires the paths to be canonicalized, because `/tmp` is symlinked to // `private/tmp`. #[allow(clippy::disallowed_methods)] static TEMPDIR_ROOT: Lazy = Lazy::new(|| dunce::canonicalize(temp_dir()).unwrap()); /// Canonicalizes [`std::env::temp_dir`] and creates a directory therein. /// /// Canonicalizing early can be useful if one wants to avoid canonicalizing later on. pub fn tempdir() -> Result { #[allow(clippy::disallowed_methods)] tempdir_in(&*TEMPDIR_ROOT) }