summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Gnatenko <ignatenko@redhat.com>2017-12-30 22:06:16 +0100
committerAndrew Gallant <jamslam@gmail.com>2017-12-30 16:06:16 -0500
commita5855a5d733d42ba3913d78dd19083990d41ecf3 (patch)
tree46aa7b5e7b93f9cb821246e97cd544e0a5f95cc9 /src
parent03b0d832edb821d2baed81e04fc82a0699935777 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/search_stream.rs11
-rw-r--r--src/unescape.rs4
2 files changed, 8 insertions, 7 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::*;