pub struct SerialCargoEnv<'a> { /* private fields */ }Expand description
RAII helper that serializes and scopes mutations of CARGO_* environment variables.
Tests that simulate different crate layouts frequently need to tweak CARGO_MANIFEST_DIR
and CARGO_PRIMARY_PACKAGE. Those environment variables are global, so concurrent mutations
can introduce racy failures. SerialCargoEnv acquires a process-wide mutex before mutating
the variables, remembers the previous values, and restores them when dropped so each test can
safely run in isolation.
Implementations§
Source§impl<'a> SerialCargoEnv<'a>
impl<'a> SerialCargoEnv<'a>
Sourcepub fn new(manifest_dir: &GuardedPath, primary: bool) -> Self
pub fn new(manifest_dir: &GuardedPath, primary: bool) -> Self
Acquire the guard and set the cargo environment to point at manifest_dir.
primary controls whether CARGO_PRIMARY_PACKAGE is set to "1" or "0".
The previous values are restored automatically when the guard drops.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SerialCargoEnv<'a>
impl<'a> RefUnwindSafe for SerialCargoEnv<'a>
impl<'a> !Send for SerialCargoEnv<'a>
impl<'a> Sync for SerialCargoEnv<'a>
impl<'a> Unpin for SerialCargoEnv<'a>
impl<'a> UnwindSafe for SerialCargoEnv<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more