Evaluate this predicate against the given haystack
(&self, haystack: &str)
| 83 | |
| 84 | /// Evaluate this predicate against the given haystack |
| 85 | pub(crate) fn evaluate(&self, haystack: &str) -> bool { |
| 86 | match self { |
| 87 | Predicate::Eq(v) => *v == haystack, |
| 88 | Predicate::IEqAscii(v) => haystack.eq_ignore_ascii_case(v), |
| 89 | Predicate::Contains(finder) => finder.find(haystack.as_bytes()).is_some(), |
| 90 | Predicate::StartsWith(v) => starts_with(haystack, v, equals_kernel), |
| 91 | Predicate::IStartsWithAscii(v) => { |
| 92 | starts_with(haystack, v, equals_ignore_ascii_case_kernel) |
| 93 | } |
| 94 | Predicate::EndsWith(v) => ends_with(haystack, v, equals_kernel), |
| 95 | Predicate::IEndsWithAscii(v) => ends_with(haystack, v, equals_ignore_ascii_case_kernel), |
| 96 | Predicate::Regex(v) => v.is_match(haystack), |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /// Evaluate this predicate against the elements of `array` |
| 101 | /// |
no test coverage detected