Skip to content

Commit

Permalink
feat(docs): mention alternative to override_temp_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
n0toose committed Nov 18, 2024
1 parent 16209da commit 4676faa
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ use once_cell::sync::OnceCell as OnceLock;
static DEFAULT_TEMPDIR: OnceLock<PathBuf> = OnceLock::new();

/// Override the default temporary directory (defaults to [`std::env::temp_dir`]). This function
/// changes the _global_ default temporary directory for the entire program and should not be called
/// except in exceptional cases where it's not configured correctly by the platform.
/// changes the default temporary directory **globally**, as in **process-wide**.
///
/// Only the first call to this function will succeed. All further calls will fail with `Err(path)`
/// where `path` is previously set default temporary directory override.
/// It only be called in exceptional cases where the temporary directory is not configured
/// correctly by the platform. Only the first call to this function will succeed. All
/// further calls will fail with `Err(path)` where `path` is the previously set default
/// temporary directory override.
///
/// You may want to use [`crate::Builder::tempdir_in`] instead, particularly if your software
/// project follows a more "object-oriented" architecture paradigm. For example, when working
/// with multiple struct objects that include a separate temporary directory field.
///
/// **NOTE:** This function does not check if the specified directory exists and/or is writable.
pub fn override_temp_dir(path: &Path) -> Result<(), PathBuf> {
Expand Down

0 comments on commit 4676faa

Please sign in to comment.