diff --git a/src/event.rs b/src/event.rs index 675830e3cdf1d25ecf039ffd3e3c08db8baf7204..387257a054820039f2c312f4c465cf93fc0b22a8 100644 --- a/src/event.rs +++ b/src/event.rs @@ -153,7 +153,7 @@ where I: Iterator<Item = Result<u8, Error>> 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::<u16>().unwrap(); let cx = nums.next().unwrap().parse::<u16>().unwrap(); @@ -192,7 +192,7 @@ where I: Iterator<Item = Result<u8, Error>> // 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::<u16>().unwrap(); let cx = nums.next().unwrap().parse::<u16>().unwrap(); @@ -203,7 +203,7 @@ where I: Iterator<Item = Result<u8, Error>> 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<I>(c: u8, iter: &mut I) -> Result<char, Error> 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 433551143b9129679c3316154c8152e8e39e0419..d395de98aead7c61d134d81dc25491778ed8f1ac 100644 --- a/src/input.rs +++ b/src/input.rs @@ -35,7 +35,7 @@ impl<I: Iterator<Item = Result<u8, io::Error>>> Iterator for Events<I> { type Item = Result<Event, io::Error>; fn next(&mut self) -> Option<Result<Event, io::Error>> { - 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 8d4a4ff833f13cbb5a50742a0f6e65bc2e899e10..e0d8ae9816cdbfb70da14c705cc728b7d75c3fee 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -75,7 +75,7 @@ impl<W: Write> 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.")); }