Skip to content

Commit c7423f1

Browse files
authored
doc(env): document the alternative to setting the tempdir (#371)
alternative to #312, I wanted to leave the rest of the docs as-is.
1 parent 5af60ca commit c7423f1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/env.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::env;
22
use std::path::{Path, PathBuf};
33

4+
#[cfg(doc)]
5+
use crate::{tempdir_in, tempfile_in, Builder};
6+
47
// Once rust 1.70 is wide-spread (Debian stable), we can use OnceLock from stdlib.
58
use once_cell::sync::OnceCell as OnceLock;
69

@@ -11,6 +14,10 @@ static DEFAULT_TEMPDIR: OnceLock<PathBuf> = OnceLock::new();
1114
/// except in exceptional cases where it's not configured correctly by the platform. Applications
1215
/// should first check if the path returned by [`env::temp_dir`] is acceptable.
1316
///
17+
/// If you're writing a library and want to control where your temporary files are placed, you
18+
/// should instead use the `_in` variants of the various temporary file/directory constructors
19+
/// ([`tempdir_in`], [`tempfile_in`], the so-named functions on [`Builder`], etc.).
20+
///
1421
/// Only the first call to this function will succeed. All further calls will fail with `Err(path)`
1522
/// where `path` is previously set default temporary directory override.
1623
///

0 commit comments

Comments
 (0)