diff --git a/src/re_bytes.rs b/src/re_bytes.rs index b86973d0b..64c09a725 100644 --- a/src/re_bytes.rs +++ b/src/re_bytes.rs @@ -37,6 +37,18 @@ impl<'t> Match<'t> { self.end } + /// Returns true if and only if this match has a length of zero. + #[inline] + pub fn is_empty(&self) -> bool { + self.start == self.end + } + + /// Returns the length, in bytes, of this match. + #[inline] + pub fn len(&self) -> usize { + self.end - self.start + } + /// Returns the range over the starting and ending byte offsets of the /// match in the haystack. #[inline] diff --git a/src/re_unicode.rs b/src/re_unicode.rs index 41bd8ac09..bee365e8d 100644 --- a/src/re_unicode.rs +++ b/src/re_unicode.rs @@ -45,6 +45,18 @@ impl<'t> Match<'t> { self.end } + /// Returns true if and only if this match has a length of zero. + #[inline] + pub fn is_empty(&self) -> bool { + self.start == self.end + } + + /// Returns the length, in bytes, of this match. + #[inline] + pub fn len(&self) -> usize { + self.end - self.start + } + /// Returns the range over the starting and ending byte offsets of the /// match in the haystack. #[inline]