predicates::path

Trait PredicateFileContentExt

Source
pub trait PredicateFileContentExt
where Self: Predicate<[u8]> + Sized,
{ // Provided method fn from_file_path(self) -> FileContentPredicate<Self> { ... } }
Expand description

Predicate extension adapting a slice Predicate.

Provided Methods§

Source

fn from_file_path(self) -> FileContentPredicate<Self>

Returns a FileContentPredicate that adapts Self to a file content Predicate.

§Examples
use predicates::prelude::*;
use std::path::Path;

let predicate_fn = predicate::str::is_empty().not().from_utf8().from_file_path();
assert_eq!(true, predicate_fn.eval(Path::new("./tests/hello_world")));
assert_eq!(false, predicate_fn.eval(Path::new("./tests/empty_file")));

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§

Source§

impl<P> PredicateFileContentExt for P
where P: Predicate<[u8]>,