From e522e69578d61d4620e38a3a50d209a4010002e6 Mon Sep 17 00:00:00 2001 From: Glenn Griffin Date: Mon, 9 Dec 2019 08:08:27 -0800 Subject: [PATCH] Remove contains. matches is more flexible. --- src/mappers.rs | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/mappers.rs b/src/mappers.rs index 28fa0af..70da2b9 100644 --- a/src/mappers.rs +++ b/src/mappers.rs @@ -48,27 +48,6 @@ impl Mapper for Any { } } -pub fn contains(value: T) -> Contains -where - T: AsRef<[u8]> + fmt::Debug + Send, -{ - Contains(value) -} -#[derive(Debug)] -pub struct Contains(T); -impl Mapper for Contains -where - T: AsRef<[u8]> + fmt::Debug + Send, - IN: AsRef<[u8]> + ?Sized, -{ - type Out = bool; - - fn map(&mut self, input: &IN) -> bool { - use bstr::ByteSlice; - input.as_ref().contains_str(self.0.as_ref()) - } -} - pub fn eq(value: T) -> Eq { Eq(value) } @@ -240,14 +219,6 @@ where mod tests { use super::*; - #[test] - fn test_contains() { - let mut c = contains("foo"); - assert_eq!(true, c.map("foobar")); - assert_eq!(true, c.map("bazfoobar")); - assert_eq!(false, c.map("bar")); - } - #[test] fn test_eq() { let mut c = eq("foo"); @@ -277,7 +248,7 @@ mod tests { #[test] fn test_all_of() { - let mut c = all_of![contains("foo"), contains("bar")]; + let mut c = all_of![matches("foo"), matches("bar")]; assert_eq!(true, c.map("foobar")); assert_eq!(true, c.map("barfoo")); assert_eq!(false, c.map("foo")); @@ -286,7 +257,7 @@ mod tests { #[test] fn test_any_of() { - let mut c = any_of![contains("foo"), contains("bar")]; + let mut c = any_of![matches("foo"), matches("bar")]; assert_eq!(true, c.map("foobar")); assert_eq!(true, c.map("barfoo")); assert_eq!(true, c.map("foo")); @@ -321,7 +292,7 @@ mod tests { #[test] fn test_lowercase() { - let mut c = lowercase(contains("foo")); + let mut c = lowercase(matches("foo")); assert_eq!(true, c.map("FOO")); assert_eq!(true, c.map("FoOBar")); assert_eq!(true, c.map("foobar"));