Upgrade rust/crates/regex to 1.5.4
Test: make
Change-Id: I0eab39246dc2aea41a62c15661e350b490f06c1d
diff --git a/src/re_bytes.rs b/src/re_bytes.rs
index 204a70a..ae55d6d 100644
--- a/src/re_bytes.rs
+++ b/src/re_bytes.rs
@@ -6,13 +6,13 @@
use std::str::FromStr;
use std::sync::Arc;
-use find_byte::find_byte;
+use crate::find_byte::find_byte;
-use error::Error;
-use exec::{Exec, ExecNoSync};
-use expand::expand_bytes;
-use re_builder::bytes::RegexBuilder;
-use re_trait::{self, RegularExpression, SubCapturesPosIter};
+use crate::error::Error;
+use crate::exec::{Exec, ExecNoSync};
+use crate::expand::expand_bytes;
+use crate::re_builder::bytes::RegexBuilder;
+use crate::re_trait::{self, RegularExpression, SubCapturesPosIter};
/// Match represents a single match of a regex in a haystack.
///
@@ -79,14 +79,14 @@
impl fmt::Display for Regex {
/// Shows the original regular expression.
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl fmt::Debug for Regex {
/// Shows the original regular expression.
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
@@ -133,7 +133,7 @@
/// bytes:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let text = b"I categorically deny having triskaidekaphobia.";
/// assert!(Regex::new(r"\b\w{13}\b").unwrap().is_match(text));
@@ -156,7 +156,7 @@
/// ASCII word bytes:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let text = b"I categorically deny having triskaidekaphobia.";
/// let mat = Regex::new(r"\b\w{13}\b").unwrap().find(text).unwrap();
@@ -177,7 +177,7 @@
/// word bytes:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let text = b"Retroactively relinquishing remunerations is reprehensible.";
/// for mat in Regex::new(r"\b\w{13}\b").unwrap().find_iter(text) {
@@ -205,7 +205,7 @@
/// year separately.
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap();
/// let text = b"Not my favorite movie: 'Citizen Kane' (1941).";
@@ -227,7 +227,7 @@
/// We can make this example a bit clearer by using *named* capture groups:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")
/// .unwrap();
@@ -271,7 +271,7 @@
/// some text, where the movie is formatted like "'Title' (xxxx)":
///
/// ```rust
- /// # extern crate regex; use std::str; use regex::bytes::Regex;
+ /// # use std::str; use regex::bytes::Regex;
/// # fn main() {
/// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")
/// .unwrap();
@@ -305,7 +305,7 @@
/// To split a string delimited by arbitrary amounts of spaces or tabs:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let re = Regex::new(r"[ \t]+").unwrap();
/// let fields: Vec<&[u8]> = re.split(b"a b \t c\td e").collect();
@@ -331,7 +331,7 @@
/// Get the first two words in some text:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let re = Regex::new(r"\W+").unwrap();
/// let fields: Vec<&[u8]> = re.splitn(b"Hey! How are you?", 3).collect();
@@ -379,7 +379,7 @@
/// In typical usage, this can just be a normal byte string:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let re = Regex::new("[^01]+").unwrap();
/// assert_eq!(re.replace(b"1078910", &b""[..]), &b"1010"[..]);
@@ -392,7 +392,7 @@
/// group matches easily:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # use regex::bytes::Captures; fn main() {
/// let re = Regex::new(r"([^,\s]+),\s+(\S+)").unwrap();
/// let result = re.replace(b"Springsteen, Bruce", |caps: &Captures| {
@@ -411,7 +411,7 @@
/// with named capture groups:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(?P<first>\S+)").unwrap();
/// let result = re.replace(b"Springsteen, Bruce", &b"$first $last"[..]);
@@ -428,7 +428,7 @@
/// underscore:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let re = Regex::new(r"(?P<first>\w+)\s+(?P<second>\w+)").unwrap();
/// let result = re.replace(b"deep fried", &b"${first}_$second"[..]);
@@ -445,7 +445,7 @@
/// byte string with `NoExpand`:
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// use regex::bytes::NoExpand;
///
@@ -546,7 +546,7 @@
/// `a`.
///
/// ```rust
- /// # extern crate regex; use regex::bytes::Regex;
+ /// # use regex::bytes::Regex;
/// # fn main() {
/// let text = b"aaaaa";
/// let pos = Regex::new(r"a+").unwrap().shortest_match(text);
@@ -658,7 +658,7 @@
}
/// Returns an iterator over the capture names.
- pub fn capture_names(&self) -> CaptureNames {
+ pub fn capture_names(&self) -> CaptureNames<'_> {
CaptureNames(self.0.capture_names().iter())
}
@@ -990,15 +990,15 @@
}
impl<'t> fmt::Debug for Captures<'t> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("Captures").field(&CapturesDebug(self)).finish()
}
}
-struct CapturesDebug<'c, 't: 'c>(&'c Captures<'t>);
+struct CapturesDebug<'c, 't>(&'c Captures<'t>);
impl<'c, 't> fmt::Debug for CapturesDebug<'c, 't> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn escape_bytes(bytes: &[u8]) -> String {
let mut s = String::new();
for &b in bytes {
@@ -1084,7 +1084,7 @@
/// The lifetime `'c` corresponds to the lifetime of the `Captures` value, and
/// the lifetime `'t` corresponds to the originally matched text.
#[derive(Clone, Debug)]
-pub struct SubCaptureMatches<'c, 't: 'c> {
+pub struct SubCaptureMatches<'c, 't> {
caps: &'c Captures<'t>,
it: SubCapturesPosIter<'c>,
}
@@ -1116,7 +1116,7 @@
///
/// For example, a no-op replacement would be
/// `dst.extend(&caps[0])`.
- fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>);
+ fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>);
/// Return a fixed unchanging replacement byte string.
///
@@ -1159,10 +1159,10 @@
///
/// Returned by [`Replacer::by_ref`](trait.Replacer.html#method.by_ref).
#[derive(Debug)]
-pub struct ReplacerRef<'a, R: ?Sized + 'a>(&'a mut R);
+pub struct ReplacerRef<'a, R: ?Sized>(&'a mut R);
impl<'a, R: Replacer + ?Sized + 'a> Replacer for ReplacerRef<'a, R> {
- fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+ fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
self.0.replace_append(caps, dst)
}
fn no_expansion<'r>(&'r mut self) -> Option<Cow<'r, [u8]>> {
@@ -1171,56 +1171,56 @@
}
impl<'a> Replacer for &'a [u8] {
- fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+ fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
caps.expand(*self, dst);
}
- fn no_expansion(&mut self) -> Option<Cow<[u8]>> {
+ fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
no_expansion(self)
}
}
impl<'a> Replacer for &'a Vec<u8> {
- fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+ fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
caps.expand(*self, dst);
}
- fn no_expansion(&mut self) -> Option<Cow<[u8]>> {
+ fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
no_expansion(self)
}
}
impl Replacer for Vec<u8> {
- fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+ fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
caps.expand(self, dst);
}
- fn no_expansion(&mut self) -> Option<Cow<[u8]>> {
+ fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
no_expansion(self)
}
}
impl<'a> Replacer for Cow<'a, [u8]> {
- fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+ fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
caps.expand(self.as_ref(), dst);
}
- fn no_expansion(&mut self) -> Option<Cow<[u8]>> {
+ fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
no_expansion(self)
}
}
impl<'a> Replacer for &'a Cow<'a, [u8]> {
- fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+ fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
caps.expand(self.as_ref(), dst);
}
- fn no_expansion(&mut self) -> Option<Cow<[u8]>> {
+ fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
no_expansion(self)
}
}
-fn no_expansion<T: AsRef<[u8]>>(t: &T) -> Option<Cow<[u8]>> {
+fn no_expansion<T: AsRef<[u8]>>(t: &T) -> Option<Cow<'_, [u8]>> {
let s = t.as_ref();
match find_byte(b'$', s) {
Some(_) => None,
@@ -1230,10 +1230,10 @@
impl<F, T> Replacer for F
where
- F: FnMut(&Captures) -> T,
+ F: FnMut(&Captures<'_>) -> T,
T: AsRef<[u8]>,
{
- fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+ fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
dst.extend_from_slice((*self)(caps).as_ref());
}
}
@@ -1250,11 +1250,11 @@
pub struct NoExpand<'t>(pub &'t [u8]);
impl<'t> Replacer for NoExpand<'t> {
- fn replace_append(&mut self, _: &Captures, dst: &mut Vec<u8>) {
+ fn replace_append(&mut self, _: &Captures<'_>, dst: &mut Vec<u8>) {
dst.extend_from_slice(self.0);
}
- fn no_expansion(&mut self) -> Option<Cow<[u8]>> {
+ fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
Some(Cow::Borrowed(self.0))
}
}