From 9db7451784f899d0f3609e8047dd6541e5837928 Mon Sep 17 00:00:00 2001
From: gwenn <gtreguier@gmail.com>
Date: Fri, 3 Mar 2017 19:42:08 +0100
Subject: [PATCH] Fix clippy warnings

---
 src/lib.rs         | 11 ++++++-----
 src/line_buffer.rs |  9 +++++----
 src/tty/unix.rs    |  6 +++---
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index dba37c98..864a354b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -665,8 +665,7 @@ fn complete_line<R: RawReader>(rdr: &mut R,
         try!(edit_move_end(s));
         s.line.set_pos(save_pos);
         // we got a second tab, maybe show list of possible completions
-        let mut show_completions = true;
-        if candidates.len() > config.completion_prompt_limit() {
+        let show_completions = if candidates.len() > config.completion_prompt_limit() {
             let msg = format!("\nDisplay all {} possibilities? (y or n)", candidates.len());
             try!(write_and_flush(s.out, msg.as_bytes()));
             s.old_rows += 1;
@@ -676,12 +675,14 @@ fn complete_line<R: RawReader>(rdr: &mut R,
                   cmd != Cmd::Kill(Movement::BackwardChar(1)) {
                 cmd = try!(s.next_cmd(rdr));
             }
-            show_completions = match cmd {
+            match cmd {
                 Cmd::SelfInsert(1, 'y') |
                 Cmd::SelfInsert(1, 'Y') => true,
                 _ => false,
-            };
-        }
+            }
+        } else {
+            true
+        };
         if show_completions {
             page_completions(rdr, s, &candidates)
         } else {
diff --git a/src/line_buffer.rs b/src/line_buffer.rs
index 91fade53..56747bc2 100644
--- a/src/line_buffer.rs
+++ b/src/line_buffer.rs
@@ -347,11 +347,12 @@ impl LineBuffer {
         }
         let mut wp = 0;
         let mut gis = self.buf[pos..].grapheme_indices(true);
-        let mut gi = None;
-        if at != At::Start {
+        let mut gi = if at != At::Start {
             // TODO Validate
-            gi = gis.next();
-        }
+            gis.next()
+        } else {
+            None
+        };
         'outer: for _ in 0..n {
             gi = gis.next();
             'inner: loop {
diff --git a/src/tty/unix.rs b/src/tty/unix.rs
index 3d78afe2..7b77b683 100644
--- a/src/tty/unix.rs
+++ b/src/tty/unix.rs
@@ -300,12 +300,12 @@ impl Term for PosixTerminal {
         let mut raw = original_mode;
         // disable BREAK interrupt, CR to NL conversion on input,
         // input parity check, strip high bit (bit 8), output flow control
-        raw.c_iflag = raw.c_iflag & !(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
+        raw.c_iflag &= !(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
         // we don't want raw output, it turns newlines into straight linefeeds
         // raw.c_oflag = raw.c_oflag & !(OPOST); // disable all output processing
-        raw.c_cflag = raw.c_cflag | (CS8); // character-size mark (8 bits)
+        raw.c_cflag |= CS8; // character-size mark (8 bits)
         // disable echoing, canonical mode, extended input processing and signals
-        raw.c_lflag = raw.c_lflag & !(ECHO | ICANON | IEXTEN | ISIG);
+        raw.c_lflag &= !(ECHO | ICANON | IEXTEN | ISIG);
         raw.c_cc[VMIN] = 1; // One character-at-a-time input
         raw.c_cc[VTIME] = 0; // with blocking read
         try!(termios::tcsetattr(STDIN_FILENO, termios::TCSADRAIN, &raw));
-- 
GitLab