diff --git a/src/event.rs b/src/event.rs index 675830e..387257a 100644 --- a/src/event.rs +++ b/src/event.rs @@ -153,7 +153,7 @@ where I: Iterator> c = iter.next().unwrap().unwrap(); } let str_buf = String::from_utf8(buf).unwrap(); - let ref mut nums = str_buf.split(';'); + let nums = &mut str_buf.split(';'); let cb = nums.next().unwrap().parse::().unwrap(); let cx = nums.next().unwrap().parse::().unwrap(); @@ -192,7 +192,7 @@ where I: Iterator> // ESC [ Cb ; Cx ; Cy ; M b'M' => { let str_buf = String::from_utf8(buf).unwrap(); - let ref mut nums = str_buf.split(';'); + let nums = &mut str_buf.split(';'); let cb = nums.next().unwrap().parse::().unwrap(); let cx = nums.next().unwrap().parse::().unwrap(); @@ -203,7 +203,7 @@ where I: Iterator> 33 => MouseEvent::Press(MouseButton::Middle, cx, cy), 34 => MouseEvent::Press(MouseButton::Right, cx, cy), 35 => MouseEvent::Release(cx, cy), - 96 => MouseEvent::Press(MouseButton::WheelUp, cx, cy), + 96 | 97 => MouseEvent::Press(MouseButton::WheelUp, cx, cy), _ => return error, }; @@ -264,14 +264,13 @@ fn parse_utf8_char(c: u8, iter: &mut I) -> Result if c.is_ascii() { Ok(c as char) } else { - let ref mut bytes = Vec::new(); + let bytes = &mut Vec::new(); bytes.push(c); loop { bytes.push(iter.next().unwrap().unwrap()); - match str::from_utf8(bytes) { - Ok(st) => return Ok(st.chars().next().unwrap()), - Err(_) => {}, + if let Ok(st) = str::from_utf8(bytes) { + return Ok(st.chars().next().unwrap()) } if bytes.len() >= 4 { return error; } } diff --git a/src/input.rs b/src/input.rs index 4335511..d395de9 100644 --- a/src/input.rs +++ b/src/input.rs @@ -35,7 +35,7 @@ impl>> Iterator for Events { type Item = Result; fn next(&mut self) -> Option> { - let ref mut iter = self.bytes; + let iter = &mut self.bytes; match iter.next() { Some(item) => Some(parse_event(item, iter).or(Ok(Event::Unsupported))), None => None, diff --git a/src/raw.rs b/src/raw.rs index 8d4a4ff..e0d8ae9 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -75,7 +75,7 @@ impl IntoRawMode for W { use termios::{cfmakeraw, get_terminal_attr, set_terminal_attr}; let (mut ios, exit) = get_terminal_attr(); - let prev_ios = ios.clone(); + let prev_ios = ios; if exit != 0 { return Err(io::Error::new(io::ErrorKind::Other, "Unable to get Termios attribute.")); }