summaryrefslogtreecommitdiffstats
path: root/grep-matcher/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'grep-matcher/src/lib.rs')
-rw-r--r--grep-matcher/src/lib.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/grep-matcher/src/lib.rs b/grep-matcher/src/lib.rs
index 9a067efa..ba59b923 100644
--- a/grep-matcher/src/lib.rs
+++ b/grep-matcher/src/lib.rs
@@ -38,13 +38,15 @@ implementations.
#![deny(missing_docs)]
-extern crate memchr;
+extern crate bstr;
use std::fmt;
use std::io;
use std::ops;
use std::u64;
+use bstr::BStr;
+
use interpolate::interpolate;
mod interpolate;
@@ -180,6 +182,22 @@ impl ops::IndexMut<Match> for [u8] {
}
}
+impl ops::Index<Match> for BStr {
+ type Output = BStr;
+
+ #[inline]
+ fn index(&self, index: Match) -> &BStr {
+ &self[index.start..index.end]
+ }
+}
+
+impl ops::IndexMut<Match> for BStr {
+ #[inline]
+ fn index_mut(&mut self, index: Match) -> &mut BStr {
+ &mut self[index.start..index.end]
+ }
+}
+
impl ops::Index<Match> for str {
type Output = str;