Function lock_current_dir

Source
pub fn lock_current_dir(
    dir: impl AsRef<Path>,
) -> Result<CurrentDirGuard, CurrentDirError>
Expand description

Set the working directory for the current process. The working directory is a form of global mutable state, so this use a mutex to ensure that only one mutation can be made at a time. This returns a guard that, when dropped, will revert the working directory to its previous value and release the lock on it.

ยงErrors

Return an error if either current_dir or set_current_dir fails. See those two functions for failure conditions. In either case, the current directory will not be modified and its mutex will remain unlocked.