mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-04 21:52:54 +02:00
edition: run 'cargo fix --edition --edition-idioms --all'
This commit is contained in:
@ -60,7 +60,7 @@ impl ColorError {
|
||||
}
|
||||
|
||||
impl fmt::Display for ColorError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
ColorError::UnrecognizedOutType(ref name) => write!(
|
||||
f,
|
||||
|
@ -507,7 +507,10 @@ impl<W: io::Write> JSON<W> {
|
||||
|
||||
/// Write the given message followed by a new line. The new line is
|
||||
/// determined from the configuration of the given searcher.
|
||||
fn write_message(&mut self, message: &jsont::Message) -> io::Result<()> {
|
||||
fn write_message(
|
||||
&mut self,
|
||||
message: &jsont::Message<'_>,
|
||||
) -> io::Result<()> {
|
||||
if self.config.pretty {
|
||||
json::to_writer_pretty(&mut self.wtr, message)?;
|
||||
} else {
|
||||
@ -552,7 +555,7 @@ impl<W> JSON<W> {
|
||||
/// * `W` refers to the underlying writer that this printer is writing its
|
||||
/// output to.
|
||||
#[derive(Debug)]
|
||||
pub struct JSONSink<'p, 's, M: Matcher, W: 's> {
|
||||
pub struct JSONSink<'p, 's, M: Matcher, W> {
|
||||
matcher: M,
|
||||
json: &'s mut JSON<W>,
|
||||
path: Option<&'p Path>,
|
||||
@ -682,7 +685,7 @@ impl<'p, 's, M: Matcher, W: io::Write> Sink for JSONSink<'p, 's, M, W> {
|
||||
fn matched(
|
||||
&mut self,
|
||||
searcher: &Searcher,
|
||||
mat: &SinkMatch,
|
||||
mat: &SinkMatch<'_>,
|
||||
) -> Result<bool, io::Error> {
|
||||
self.write_begin_message()?;
|
||||
|
||||
@ -724,7 +727,7 @@ impl<'p, 's, M: Matcher, W: io::Write> Sink for JSONSink<'p, 's, M, W> {
|
||||
fn context(
|
||||
&mut self,
|
||||
searcher: &Searcher,
|
||||
ctx: &SinkContext,
|
||||
ctx: &SinkContext<'_>,
|
||||
) -> Result<bool, io::Error> {
|
||||
self.write_begin_message()?;
|
||||
self.json.matches.clear();
|
||||
@ -836,7 +839,7 @@ impl<'a> SubMatches<'a> {
|
||||
}
|
||||
|
||||
/// Return this set of match ranges as a slice.
|
||||
fn as_slice(&self) -> &[jsont::SubMatch] {
|
||||
fn as_slice(&self) -> &[jsont::SubMatch<'_>] {
|
||||
match *self {
|
||||
SubMatches::Empty => &[],
|
||||
SubMatches::Small(ref x) => x,
|
||||
|
@ -90,7 +90,7 @@ enum Data<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Data<'a> {
|
||||
fn from_bytes(bytes: &[u8]) -> Data {
|
||||
fn from_bytes(bytes: &[u8]) -> Data<'_> {
|
||||
match str::from_utf8(bytes) {
|
||||
Ok(text) => Data::Text { text: Cow::Borrowed(text) },
|
||||
Err(_) => Data::Bytes { bytes },
|
||||
@ -98,7 +98,7 @@ impl<'a> Data<'a> {
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn from_path(path: &Path) -> Data {
|
||||
fn from_path(path: &Path) -> Data<'_> {
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
|
||||
match path.to_str() {
|
||||
|
@ -70,19 +70,17 @@ fn example() -> Result<(), Box<Error>> {
|
||||
|
||||
#[cfg(feature = "serde1")]
|
||||
extern crate base64;
|
||||
extern crate bstr;
|
||||
extern crate grep_matcher;
|
||||
#[cfg(test)]
|
||||
extern crate grep_regex;
|
||||
extern crate grep_searcher;
|
||||
#[cfg(feature = "serde1")]
|
||||
extern crate serde;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[cfg(feature = "serde1")]
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[cfg(feature = "serde1")]
|
||||
extern crate serde_json;
|
||||
extern crate termcolor;
|
||||
|
||||
|
||||
pub use crate::color::{
|
||||
default_color_specs, ColorError, ColorSpecs, UserColorSpec,
|
||||
|
@ -625,7 +625,7 @@ impl<W> Standard<W> {
|
||||
/// * `W` refers to the underlying writer that this printer is writing its
|
||||
/// output to.
|
||||
#[derive(Debug)]
|
||||
pub struct StandardSink<'p, 's, M: Matcher, W: 's> {
|
||||
pub struct StandardSink<'p, 's, M: Matcher, W> {
|
||||
matcher: M,
|
||||
standard: &'s mut Standard<W>,
|
||||
replacer: Replacer<M>,
|
||||
@ -784,7 +784,7 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for StandardSink<'p, 's, M, W> {
|
||||
fn matched(
|
||||
&mut self,
|
||||
searcher: &Searcher,
|
||||
mat: &SinkMatch,
|
||||
mat: &SinkMatch<'_>,
|
||||
) -> Result<bool, io::Error> {
|
||||
self.match_count += 1;
|
||||
// When we've exceeded our match count, then the remaining context
|
||||
@ -825,7 +825,7 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for StandardSink<'p, 's, M, W> {
|
||||
fn context(
|
||||
&mut self,
|
||||
searcher: &Searcher,
|
||||
ctx: &SinkContext,
|
||||
ctx: &SinkContext<'_>,
|
||||
) -> Result<bool, io::Error> {
|
||||
self.standard.matches.clear();
|
||||
self.replacer.clear();
|
||||
@ -904,7 +904,7 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for StandardSink<'p, 's, M, W> {
|
||||
/// A StandardImpl is initialized every time a match or a contextual line is
|
||||
/// reported.
|
||||
#[derive(Debug)]
|
||||
struct StandardImpl<'a, M: 'a + Matcher, W: 'a> {
|
||||
struct StandardImpl<'a, M: Matcher, W> {
|
||||
searcher: &'a Searcher,
|
||||
sink: &'a StandardSink<'a, 'a, M, W>,
|
||||
sunk: Sunk<'a>,
|
||||
@ -916,7 +916,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> {
|
||||
/// Bundle self with a searcher and return the core implementation of Sink.
|
||||
fn new(
|
||||
searcher: &'a Searcher,
|
||||
sink: &'a StandardSink<M, W>,
|
||||
sink: &'a StandardSink<'_, '_, M, W>,
|
||||
) -> StandardImpl<'a, M, W> {
|
||||
StandardImpl {
|
||||
searcher: searcher,
|
||||
@ -930,7 +930,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> {
|
||||
/// for use with handling matching lines.
|
||||
fn from_match(
|
||||
searcher: &'a Searcher,
|
||||
sink: &'a StandardSink<M, W>,
|
||||
sink: &'a StandardSink<'_, '_, M, W>,
|
||||
mat: &'a SinkMatch<'a>,
|
||||
) -> StandardImpl<'a, M, W> {
|
||||
let sunk = Sunk::from_sink_match(
|
||||
@ -945,7 +945,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> {
|
||||
/// for use with handling contextual lines.
|
||||
fn from_context(
|
||||
searcher: &'a Searcher,
|
||||
sink: &'a StandardSink<M, W>,
|
||||
sink: &'a StandardSink<'_, '_, M, W>,
|
||||
ctx: &'a SinkContext<'a>,
|
||||
) -> StandardImpl<'a, M, W> {
|
||||
let sunk = Sunk::from_sink_context(
|
||||
|
@ -457,7 +457,7 @@ impl<W> Summary<W> {
|
||||
/// * `W` refers to the underlying writer that this printer is writing its
|
||||
/// output to.
|
||||
#[derive(Debug)]
|
||||
pub struct SummarySink<'p, 's, M: Matcher, W: 's> {
|
||||
pub struct SummarySink<'p, 's, M: Matcher, W> {
|
||||
matcher: M,
|
||||
summary: &'s mut Summary<W>,
|
||||
path: Option<PrinterPath<'p>>,
|
||||
@ -591,7 +591,7 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for SummarySink<'p, 's, M, W> {
|
||||
fn matched(
|
||||
&mut self,
|
||||
searcher: &Searcher,
|
||||
mat: &SinkMatch,
|
||||
mat: &SinkMatch<'_>,
|
||||
) -> Result<bool, io::Error> {
|
||||
let is_multi_line = self.multi_line(searcher);
|
||||
let sink_match_count = if self.stats.is_none() && !is_multi_line {
|
||||
|
@ -29,7 +29,7 @@ struct Space<M: Matcher> {
|
||||
}
|
||||
|
||||
impl<M: Matcher> fmt::Debug for Replacer<M> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let (dst, matches) = self.replacement().unwrap_or((&[], &[]));
|
||||
f.debug_struct("Replacer")
|
||||
.field("dst", &dst)
|
||||
@ -330,7 +330,7 @@ impl<'a> PrinterPath<'a> {
|
||||
pub struct NiceDuration(pub time::Duration);
|
||||
|
||||
impl fmt::Display for NiceDuration {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:0.6}s", self.fractional_seconds())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user