From 030c9a3d865f1252c4ee666a307103e55273004c Mon Sep 17 00:00:00 2001 From: Pierre Chifflier Date: Wed, 30 Oct 2019 17:17:32 +0100 Subject: [PATCH] rust: add take_until_and_consume replacement function --- rust/src/common.rs | 12 ++++++++++++ rust/src/lib.rs | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 rust/src/common.rs diff --git a/rust/src/common.rs b/rust/src/common.rs new file mode 100644 index 0000000000..3ed1ef38ff --- /dev/null +++ b/rust/src/common.rs @@ -0,0 +1,12 @@ +#[macro_export] +macro_rules! take_until_and_consume ( + ( $i:expr, $needle:expr ) => ( + { + let input: &[u8] = $i; + + let (rem, res) = ::nom::take_until!(input, $needle)?; + let (rem, _) = ::nom::take!(rem, $needle.len())?; + Ok((rem, res)) + } + ); +); diff --git a/rust/src/lib.rs b/rust/src/lib.rs index e0955b1a41..81ada2101c 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -40,6 +40,8 @@ pub mod log; #[macro_use] pub mod core; +#[macro_use] +pub mod common; pub mod conf; pub mod json; #[macro_use]