1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Encapsulated `std::env::set_var` / `remove_var` for unit tests (G-UNSAFE-03/04).
//!
//! `set_var`/`remove_var` are `unsafe fn` (edition 2024 requires `unsafe {}` at
//! the call site; edition 2021 still treats them as deprecated-safe). We always
//! use an explicit `unsafe` block with a `SAFETY:` proof so the crate is
//! ed2024-ready and audit-friendly.
use OsStr;
/// Sets a process environment variable for an isolated serial test.
///
/// # Safety contract (caller)
///
/// Callers must guarantee no concurrent threads in this process read or write
/// the environment for the duration of the mutation window (use
/// `#[serial_test::serial]` on the test).
/// Removes a process environment variable for an isolated serial test.
///
/// # Safety contract (caller)
///
/// Same as [`set_var`]: serial/single-thread isolation required.