[][src]Function testdir::with_testdir

pub fn with_testdir<F, R>(func: F) -> R where
    F: FnOnce(&NumberedDir) -> R, 

Executes a function passing the global NumberedDir instance.

This is used by the testdir! macro to create subdirectories inside one global NumberedDir instance for each test using NumberedDir::create_subdir. You may use this for similar purposes.

Be aware that you should have called init_testdir before calling this so that the global testdir was initialised correctly. Otherwise you will get a dummy testdir name.

Examples

use testdir::{init_testdir, with_testdir};

init_testdir!();
let path = with_testdir(|dir| dir.create_subdir("some/path"));
assert!(path.is_dir());
assert!(path.ends_with("some/path"));