From 3deb9614130306141866b27de0dedaae783a8efe Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 27 Aug 2022 22:48:10 +0300 Subject: [PATCH] BytesPattern from tupple --- lib/src/lib.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 0b77b95..839cd2e 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -57,11 +57,19 @@ impl From<&str> for BytesPattern { } } + let bytes = HEXUPPER + .decode(elements.join("").as_bytes()) + .expect("decode pattern"); + + Self::from((bytes, mask)) + } +} + +impl From<(Vec, Vec)> for BytesPattern { + fn from(x: (Vec, Vec)) -> Self { let mut s = Self { - bytes: HEXUPPER - .decode(elements.join("").as_bytes()) - .expect("decode pattern"), - mask, + bytes: x.0, + mask: x.1, pi: Vec::::new(), }; s.prefix_function();