Trait PathChild

Source
pub trait PathChild {
    // Required method
    fn child<P>(&self, path: P) -> ChildPath
       where P: AsRef<Path>;
}
Expand description

Access paths within TempDir for testing.

See ChildPath trait implementations.

use assert_fs::prelude::*;

let temp = assert_fs::TempDir::new().unwrap();
let input_file = temp.child("foo.txt");
input_file.touch().unwrap();
temp.close().unwrap();

Required Methods§

Source

fn child<P>(&self, path: P) -> ChildPath
where P: AsRef<Path>,

Access a path within the temp directory.

§Examples
use assert_fs::prelude::*;

let temp = assert_fs::TempDir::new().unwrap();
println!("{}", temp.path().display());
println!("{}", temp.child("foo/bar.txt").path().display());
temp.close().unwrap();

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§