`Predicate` extension adapting a `slice` Predicate.
| 96 | |
| 97 | /// `Predicate` extension adapting a `slice` Predicate. |
| 98 | pub trait PredicateFileContentExt |
| 99 | where |
| 100 | Self: Predicate<[u8]>, |
| 101 | Self: Sized, |
| 102 | { |
| 103 | /// Returns a `FileContentPredicate` that adapts `Self` to a file content `Predicate`. |
| 104 | /// |
| 105 | /// # Examples |
| 106 | /// |
| 107 | /// ``` |
| 108 | /// use predicates::prelude::*; |
| 109 | /// use std::path::Path; |
| 110 | /// |
| 111 | /// let predicate_fn = predicate::str::is_empty().not().from_utf8().from_file_path(); |
| 112 | /// assert_eq!(true, predicate_fn.eval(Path::new("./tests/hello_world"))); |
| 113 | /// assert_eq!(false, predicate_fn.eval(Path::new("./tests/empty_file"))); |
| 114 | /// ``` |
| 115 | #[allow(clippy::wrong_self_convention)] |
| 116 | fn from_file_path(self) -> FileContentPredicate<Self> { |
| 117 | FileContentPredicate { p: self } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | impl<P> PredicateFileContentExt for P where P: Predicate<[u8]> {} |
nothing calls this directly
no outgoing calls
no test coverage detected