Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): mention alternative to override_temp_dir #312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading