check mask length
This commit is contained in:
		@@ -73,6 +73,9 @@ impl FromStr for BytesPattern {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
impl From<(Vec<u8>, Vec<bool>)> for BytesPattern {
 | 
					impl From<(Vec<u8>, Vec<bool>)> for BytesPattern {
 | 
				
			||||||
    fn from(x: (Vec<u8>, Vec<bool>)) -> Self {
 | 
					    fn from(x: (Vec<u8>, Vec<bool>)) -> Self {
 | 
				
			||||||
 | 
					        if x.0.len() != x.1.len() {
 | 
				
			||||||
 | 
					            panic!("mask length mismatch");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        let mut s = Self {
 | 
					        let mut s = Self {
 | 
				
			||||||
            bytes: x.0,
 | 
					            bytes: x.0,
 | 
				
			||||||
            mask: x.1,
 | 
					            mask: x.1,
 | 
				
			||||||
@@ -255,4 +258,10 @@ mod tests {
 | 
				
			|||||||
        ];
 | 
					        ];
 | 
				
			||||||
        assert_eq!(mask, pattern.mask);
 | 
					        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]));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user