Upgrade rust/crates/regex to 1.4.3
Test: make
Change-Id: I0a2f64e0e7e81dc3e46c5c21ffa0bfbc7b1fb28f
diff --git a/src/re_trait.rs b/src/re_trait.rs
index d14a9f7..ea6be9c 100644
--- a/src/re_trait.rs
+++ b/src/re_trait.rs
@@ -1,3 +1,6 @@
+use std::fmt;
+use std::iter::FusedIterator;
+
/// Slot is a single saved capture location. Note that there are two slots for
/// every capture in a regular expression (one slot each for the start and end
/// of the capture).
@@ -51,7 +54,7 @@
/// Positions are byte indices in terms of the original string matched.
///
/// `'c` is the lifetime of the captures.
-#[derive(Clone)]
+#[derive(Clone, Debug)]
pub struct SubCapturesPosIter<'c> {
idx: usize,
locs: &'c Locations,
@@ -73,6 +76,8 @@
}
}
+impl<'c> FusedIterator for SubCapturesPosIter<'c> {}
+
/// `RegularExpression` describes types that can implement regex searching.
///
/// This trait is my attempt at reducing code duplication and to standardize
@@ -85,9 +90,9 @@
/// somewhat reasonable. One particular thing this trait would expose would be
/// the ability to start the search of a regex anywhere in a haystack, which
/// isn't possible in the current public API.
-pub trait RegularExpression: Sized {
+pub trait RegularExpression: Sized + fmt::Debug {
/// The type of the haystack.
- type Text: ?Sized;
+ type Text: ?Sized + fmt::Debug;
/// The number of capture slots in the compiled regular expression. This is
/// always two times the number of capture groups (two slots per group).
@@ -145,6 +150,7 @@
}
/// An iterator over all non-overlapping successive leftmost-first matches.
+#[derive(Debug)]
pub struct Matches<'t, R>
where
R: RegularExpression,
@@ -205,8 +211,16 @@
}
}
+impl<'t, R> FusedIterator for Matches<'t, R>
+where
+ R: RegularExpression,
+ R::Text: 't + AsRef<[u8]>,
+{
+}
+
/// An iterator over all non-overlapping successive leftmost-first matches with
/// captures.
+#[derive(Debug)]
pub struct CaptureMatches<'t, R>(Matches<'t, R>)
where
R: RegularExpression,
@@ -260,3 +274,10 @@
Some(locs)
}
}
+
+impl<'t, R> FusedIterator for CaptureMatches<'t, R>
+where
+ R: RegularExpression,
+ R::Text: 't + AsRef<[u8]>,
+{
+}