nom::take_until_and_consume!
[−]
[src]
macro_rules! take_until_and_consume( ($i:expr, $inp:expr) => ( { #[inline(always)] fn as_bytes<T: $crate::AsBytes>(b: &T) -> &[u8] { b.as_bytes() } let expected = $inp; let bytes = as_bytes(&expected); let mut index = 0; let mut parsed = false; for idx in 0..$i.len() { if idx + bytes.len() > $i.len() { index = idx; break; } if &$i[idx..idx + bytes.len()] == bytes { parsed = true; index = idx; break; } } if index + bytes.len() > $i.len() { $crate::IResult::Incomplete($crate::Needed::Size(index + bytes.len())) } else { if parsed { $crate::IResult::Done(&$i[(index + bytes.len())..], &$i[0..index]) } else { $crate::IResult::Error($crate::Err::Position($crate::ErrorCode::TakeUntilAndConsume as u32,$i)) } } } ); );
take_until_and_consume!(tag) => &[T] -> IResult<&[T], &[T]>
generates a parser consuming bytes until the specified byte sequence is found