From a5855a5d733d42ba3913d78dd19083990d41ecf3 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenko@redhat.com>
Date: Sat, 30 Dec 2017 22:06:16 +0100
Subject: [PATCH] couple of trivial fixes to make clippy a bit more happy
 (#704)

clippy: fix a few lints

The fixes are:

  * Use single quotes for single-character
  * Use ticks in documentation when necessary.
  * Just bow to clippy's wisdom.
---
 src/search_stream.rs | 11 ++++++-----
 src/unescape.rs      |  4 ++--
 tests/tests.rs       |  2 +-
 tests/workdir.rs     |  2 +-
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/search_stream.rs b/src/search_stream.rs
index b2b49d24..4e167121 100644
--- a/src/search_stream.rs
+++ b/src/search_stream.rs
@@ -327,16 +327,17 @@ impl<'a, R: io::Read, W: WriteColor> Searcher<'a, R, W> {
 
     #[inline(always)]
     fn fill(&mut self) -> Result<bool, Error> {
-        let mut keep = self.inp.lastnl;
-        if self.opts.before_context > 0 || self.opts.after_context > 0 {
+        let keep = if self.opts.before_context > 0 || self.opts.after_context > 0 {
             let lines = 1 + cmp::max(
                 self.opts.before_context, self.opts.after_context);
-            keep = start_of_previous_lines(
+            start_of_previous_lines(
                 self.opts.eol,
                 &self.inp.buf,
                 self.inp.lastnl.saturating_sub(1),
-                lines);
-        }
+                lines)
+        } else {
+            self.inp.lastnl
+        };
         if keep < self.last_printed {
             self.last_printed -= keep;
         } else {
diff --git a/src/unescape.rs b/src/unescape.rs
index 5d7a50e8..c27e6e28 100644
--- a/src/unescape.rs
+++ b/src/unescape.rs
@@ -14,8 +14,8 @@ enum State {
 /// Unescapes a string given on the command line. It supports a limited set of
 /// escape sequences:
 ///
-/// * \t, \r and \n are mapped to their corresponding ASCII bytes.
-/// * \xZZ hexadecimal escapes are mapped to their byte.
+/// * `\t`, `\r` and `\n` are mapped to their corresponding ASCII bytes.
+/// * `\xZZ` hexadecimal escapes are mapped to their byte.
 pub fn unescape(s: &str) -> Vec<u8> {
     use self::State::*;
 
diff --git a/tests/tests.rs b/tests/tests.rs
index 395514b2..0c5b4daf 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -62,7 +62,7 @@ fn paths(unix: &[&str]) -> Vec<String> {
 
 fn paths_from_stdout(stdout: String) -> Vec<String> {
     let mut paths: Vec<_> = stdout.lines().map(|s| {
-        s.split(":").next().unwrap().to_string()
+        s.split(':').next().unwrap().to_string()
     }).collect();
     paths.sort();
     paths
diff --git a/tests/workdir.rs b/tests/workdir.rs
index 1433f835..ea5408a4 100644
--- a/tests/workdir.rs
+++ b/tests/workdir.rs
@@ -13,7 +13,7 @@ use std::time::Duration;
 static TEST_DIR: &'static str = "ripgrep-tests";
 static NEXT_ID: AtomicUsize = ATOMIC_USIZE_INIT;
 
-/// WorkDir represents a directory in which tests are run.
+/// `WorkDir` represents a directory in which tests are run.
 ///
 /// Directories are created from a global atomic counter to avoid duplicates.
 #[derive(Debug)]