summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonardo Yvens <leoyvens@gmail.com>2016-12-23 17:53:35 -0200
committerAndrew Gallant <jamslam@gmail.com>2016-12-23 14:53:35 -0500
commitdd5ded2f78145755208043db1027cdb85ac9fd5a (patch)
tree4a4541ba35332fb7e9af9d7b26ec17bf3602b2cc /src
parentcbacf4f19ea3a73f04070d942b217b333cf88e67 (diff)
fix some clippy lints (#288)
Diffstat (limited to 'src')
-rw-r--r--src/args.rs10
-rw-r--r--src/pathutil.rs4
-rw-r--r--src/printer.rs2
-rw-r--r--src/search_buffer.rs4
-rw-r--r--src/search_stream.rs12
-rw-r--r--src/unescape.rs8
-rw-r--r--src/worker.rs2
7 files changed, 21 insertions, 21 deletions
diff --git a/src/args.rs b/src/args.rs
index 77421c4b..b999d493 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -26,7 +26,7 @@ use worker::{Worker, WorkerBuilder};
use {Result, version};
-/// Args are transformed/normalized from ArgMatches.
+/// `Args` are transformed/normalized from `ArgMatches`.
#[derive(Debug)]
pub struct Args {
paths: Vec<PathBuf>,
@@ -80,12 +80,12 @@ impl Args {
let matches = app::app_short().get_matches();
if matches.is_present("help-short") {
let _ = ::app::app_short().print_help();
- let _ = println!("");
+ println!("");
process::exit(0);
}
if matches.is_present("help") {
let _ = ::app::app_long().print_help();
- let _ = println!("");
+ println!("");
process::exit(0);
}
if matches.is_present("version") {
@@ -264,7 +264,7 @@ impl Args {
}
}
-/// ArgMatches wraps clap::ArgMatches and provides semantic meaning to several
+/// `ArgMatches` wraps `clap::ArgMatches` and provides semantic meaning to several
/// options/flags.
struct ArgMatches<'a>(clap::ArgMatches<'a>);
@@ -723,7 +723,7 @@ impl<'a> ArgMatches<'a> {
/// Like values_of_lossy, but returns an empty vec if the flag is not
/// present.
fn values_of_lossy_vec(&self, name: &str) -> Vec<String> {
- self.values_of_lossy(name).unwrap_or(vec![])
+ self.values_of_lossy(name).unwrap_or_else(Vec::new)
}
/// Safely reads an arg value with the given name, and if it's present,
diff --git a/src/pathutil.rs b/src/pathutil.rs
index 085c9dbc..8d1c1510 100644
--- a/src/pathutil.rs
+++ b/src/pathutil.rs
@@ -1,6 +1,6 @@
/*!
The pathutil module provides platform specific operations on paths that are
-typically faster than the same operations as provided in std::path. In
+typically faster than the same operations as provided in `std::path`. In
particular, we really want to avoid the costly operation of parsing the path
into its constituent components. We give up on Windows, but on Unix, we deal
with the raw bytes directly.
@@ -26,7 +26,7 @@ pub fn strip_prefix<'a, P: AsRef<Path> + ?Sized>(
if prefix.len() > path.len() || prefix != &path[0..prefix.len()] {
None
} else {
- Some(&Path::new(OsStr::from_bytes(&path[prefix.len()..])))
+ Some(Path::new(OsStr::from_bytes(&path[prefix.len()..])))
}
}
diff --git a/src/printer.rs b/src/printer.rs
index 0a75f949..6b88ace5 100644
--- a/src/printer.rs
+++ b/src/printer.rs
@@ -579,7 +579,7 @@ impl FromStr for Spec {
type Err = Error;
fn from_str(s: &str) -> Result<Spec, Error> {
- let pieces: Vec<&str> = s.split(":").collect();
+ let pieces: Vec<&str> = s.split(':').collect();
if pieces.len() <= 1 || pieces.len() > 3 {
return Err(Error::InvalidFormat(s.to_string()));
}
diff --git a/src/search_buffer.rs b/src/search_buffer.rs
index 1e8cfe8f..2b792b5c 100644
--- a/src/search_buffer.rs
+++ b/src/search_buffer.rs
@@ -1,9 +1,9 @@
/*!
-The search_buffer module is responsible for searching a single file all in a
+The `search_buffer` module is responsible for searching a single file all in a
single buffer. Typically, the source of the buffer is a memory map. This can
be useful for when memory maps are faster than streaming search.
-Note that this module doesn't quite support everything that search_stream does.
+Note that this module doesn't quite support everything that `search_stream` does.
Notably, showing contexts.
*/
use std::cmp;
diff --git a/src/search_stream.rs b/src/search_stream.rs
index d5447451..a7366295 100644
--- a/src/search_stream.rs
+++ b/src/search_stream.rs
@@ -1,5 +1,5 @@
/*!
-The search_stream module is responsible for searching a single file and
+The `search_stream` module is responsible for searching a single file and
printing matches. In particular, it searches the file in a streaming fashion
using `read` calls and a (roughly) fixed size buffer.
*/
@@ -272,7 +272,7 @@ impl<'a, R: io::Read, W: WriteColor> Searcher<'a, R, W> {
while !self.terminate() && self.inp.pos < self.inp.lastnl {
let matched = self.grep.read_match(
&mut self.last_match,
- &mut self.inp.buf[..self.inp.lastnl],
+ &self.inp.buf[..self.inp.lastnl],
self.inp.pos);
if self.opts.invert_match {
let upto =
@@ -331,12 +331,12 @@ impl<'a, R: io::Read, W: WriteColor> Searcher<'a, R, W> {
lines);
}
if keep < self.last_printed {
- self.last_printed = self.last_printed - keep;
+ self.last_printed -= keep;
} else {
self.last_printed = 0;
}
if keep <= self.last_line {
- self.last_line = self.last_line - keep;
+ self.last_line -= keep;
} else {
self.count_lines(keep);
self.last_line = 0;
@@ -457,7 +457,7 @@ impl<'a, R: io::Read, W: WriteColor> Searcher<'a, R, W> {
}
}
-/// InputBuffer encapsulates the logic of maintaining a ~fixed sized buffer
+/// `InputBuffer` encapsulates the logic of maintaining a ~fixed sized buffer
/// on which to search. There are three key pieces of complexity:
///
/// 1. We must be able to handle lines that are longer than the size of the
@@ -473,7 +473,7 @@ impl<'a, R: io::Read, W: WriteColor> Searcher<'a, R, W> {
/// may occur at the beginning of a buffer, in which case, lines at the end
/// of the previous contents of the buffer need to be printed.
///
-/// An InputBuffer is designed to be reused and isn't tied to any particular
+/// An `InputBuffer` is designed to be reused and isn't tied to any particular
/// reader.
pub struct InputBuffer {
/// The number of bytes to attempt to read at a time. Once set, this is
diff --git a/src/unescape.rs b/src/unescape.rs
index c2e11e59..5d7a50e8 100644
--- a/src/unescape.rs
+++ b/src/unescape.rs
@@ -30,7 +30,7 @@ pub fn unescape(s: &str) -> Vec<u8> {
't' => { bytes.push(b'\t'); state = Literal; }
'x' => { state = HexFirst; }
c => {
- bytes.extend(&format!(r"\{}", c).into_bytes());
+ bytes.extend(format!(r"\{}", c).into_bytes());
state = Literal;
}
}
@@ -41,7 +41,7 @@ pub fn unescape(s: &str) -> Vec<u8> {
state = HexSecond(c);
}
c => {
- bytes.extend(&format!(r"\x{}", c).into_bytes());
+ bytes.extend(format!(r"\x{}", c).into_bytes());
state = Literal;
}
}
@@ -56,7 +56,7 @@ pub fn unescape(s: &str) -> Vec<u8> {
}
c => {
let original = format!(r"\x{}{}", first, c);
- bytes.extend(&original.into_bytes());
+ bytes.extend(original.into_bytes());
state = Literal;
}
}
@@ -72,7 +72,7 @@ pub fn unescape(s: &str) -> Vec<u8> {
match state {
Escape => bytes.push(b'\\'),
HexFirst => bytes.extend(b"\\x"),
- HexSecond(c) => bytes.extend(&format!("\\x{}", c).into_bytes()),
+ HexSecond(c) => bytes.extend(format!("\\x{}", c).into_bytes()),
Literal => {}
}
bytes
diff --git a/src/worker.rs b/src/worker.rs
index 59198dd5..60dde722 100644
--- a/src/worker.rs
+++ b/src/worker.rs
@@ -199,7 +199,7 @@ impl Worker {
Work::Stdin => {
let stdin = io::stdin();
let stdin = stdin.lock();
- self.search(printer, &Path::new("<stdin>"), stdin)
+ self.search(printer, Path::new("<stdin>"), stdin)
}
Work::DirEntry(dent) => {
let mut path = dent.path();