diff --git a/lib/src/lib.rs b/lib/src/lib.rs index c139a77..8122d73 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -73,6 +73,9 @@ impl FromStr for BytesPattern { impl From<(Vec, Vec)> for BytesPattern { fn from(x: (Vec, Vec)) -> Self { + if x.0.len() != x.1.len() { + panic!("mask length mismatch"); + } let mut s = Self { bytes: x.0, mask: x.1, @@ -255,4 +258,10 @@ mod tests { ]; assert_eq!(mask, pattern.mask); } + + #[test] + #[should_panic(expected = "mask length mismatch")] + fn pattern_from_tupple_wrong_mask_length() { + let _pattern = BytesPattern::from((vec![1u8, 2u8, 3u8], vec![true, false])); + } }