pub trait PathAssert {
// Required method
fn assert<I, P>(&self, pred: I) -> &Self
where I: IntoUtf8PathPredicate<P>,
P: Predicate<Utf8Path>;
}Expand description
Assert the state of files within a Utf8TempDir.
This uses IntoUtf8PathPredicate to provide short-hands for common cases,
accepting:
Predicate<Utf8Path>orPredicate<Path>for validating a path.Predicate<str>for validating the content of the file.&[u8]or&strrepresenting the content of the file.
Note that both Predicate<Utf8Path> and Predicate<Path> (such as those in
predicates::path) can be used for validating paths.
See predicates for more predicates.
§Examples
use camino_tempfile_ext::prelude::*;
use predicates::prelude::*;
let temp = Utf8TempDir::new().unwrap();
let input_file = temp.child("foo.txt");
input_file.touch().unwrap();
// ... do something with input_file ...
input_file.assert("");
temp.child("bar.txt").assert(predicate::path::missing());
temp.close().unwrap();Required Methods§
Sourcefn assert<I, P>(&self, pred: I) -> &Selfwhere
I: IntoUtf8PathPredicate<P>,
P: Predicate<Utf8Path>,
fn assert<I, P>(&self, pred: I) -> &Selfwhere
I: IntoUtf8PathPredicate<P>,
P: Predicate<Utf8Path>,
Assert the state of files within a Utf8TempDir.
This uses IntoUtf8PathPredicate to provide short-hands for common cases,
accepting:
Predicate<Path>for validating a path.Predicate<str>for validating the content of the file.&[u8]or&strrepresenting the content of the file.
Note that accepted predicates are of type Predicate<Path>, not
Predicate<Utf8Path>, so that predicates from predicates::path can be
used.
See predicates for more predicates.
§Examples
use camino_tempfile_ext::prelude::*;
use predicates::prelude::*;
let temp = Utf8TempDir::new().unwrap();
let input_file = temp.child("foo.txt");
input_file.touch().unwrap();
// ... do something with input_file ...
input_file.assert("");
temp.child("bar.txt").assert(predicate::path::missing());
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.