diff --git a/src/color.rs b/src/color.rs index 6c543b6..b0bfcf2 100644 --- a/src/color.rs +++ b/src/color.rs @@ -76,7 +76,7 @@ derive_color!("High-intensity light magenta.", LightMagenta, "13"); derive_color!("High-intensity light cyan.", LightCyan, "14"); derive_color!("High-intensity light white.", LightWhite, "15"); -impl<'a> Color for &'a Color { +impl<'a> Color for &'a dyn Color { #[inline] fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result { (*self).write_fg(f) @@ -283,7 +283,7 @@ impl DetectColors for W { } /// Detect a color using OSC 4. -fn detect_color(stdout: &mut Write, stdin: &mut Read, color: u16) -> io::Result { +fn detect_color(stdout: &mut dyn Write, stdin: &mut dyn Read, color: u16) -> io::Result { // Is the color available? // Use `ESC ] 4 ; color ; ? BEL`. write!(stdout, "\x1B]4;{};?\x07", color)?; diff --git a/src/event.rs b/src/event.rs index 4cf45cf..cbf7dd7 100644 --- a/src/event.rs +++ b/src/event.rs @@ -110,7 +110,7 @@ pub fn parse_event(item: u8, iter: &mut I) -> Result Some(Ok(b'O')) => { match iter.next() { // F1-F4 - Some(Ok(val @ b'P'...b'S')) => Event::Key(Key::F(1 + val - b'P')), + Some(Ok(val @ b'P'..=b'S')) => Event::Key(Key::F(1 + val - b'P')), _ => return Err(error), } } @@ -128,8 +128,8 @@ pub fn parse_event(item: u8, iter: &mut I) -> Result b'\n' | b'\r' => Ok(Event::Key(Key::Char('\n'))), b'\t' => Ok(Event::Key(Key::Char('\t'))), b'\x7F' => Ok(Event::Key(Key::Backspace)), - c @ b'\x01'...b'\x1A' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1 + b'a') as char))), - c @ b'\x1C'...b'\x1F' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1C + b'4') as char))), + c @ b'\x01'..=b'\x1A' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1 + b'a') as char))), + c @ b'\x1C'..=b'\x1F' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1C + b'4') as char))), b'\0' => Ok(Event::Key(Key::Null)), c => { Ok({ @@ -148,7 +148,7 @@ fn parse_csi(iter: &mut I) -> Option { Some(match iter.next() { Some(Ok(b'[')) => match iter.next() { - Some(Ok(val @ b'A'...b'E')) => Event::Key(Key::F(1 + val - b'A')), + Some(Ok(val @ b'A'..=b'E')) => Event::Key(Key::F(1 + val - b'A')), _ => return None, }, Some(Ok(b'D')) => Event::Key(Key::Left), @@ -215,7 +215,7 @@ fn parse_csi(iter: &mut I) -> Option .unwrap(); let event = match cb { - 0...2 | 64...65 => { + 0..=2 | 64..=65 => { let button = match cb { 0 => MouseButton::Left, 1 => MouseButton::Middle, @@ -237,7 +237,7 @@ fn parse_csi(iter: &mut I) -> Option Event::Mouse(event) } - Some(Ok(c @ b'0'...b'9')) => { + Some(Ok(c @ b'0'..=b'9')) => { // Numbered escape code. let mut buf = Vec::new(); buf.push(c); @@ -298,9 +298,9 @@ fn parse_csi(iter: &mut I) -> Option 4 | 8 => Event::Key(Key::End), 5 => Event::Key(Key::PageUp), 6 => Event::Key(Key::PageDown), - v @ 11...15 => Event::Key(Key::F(v - 10)), - v @ 17...21 => Event::Key(Key::F(v - 11)), - v @ 23...24 => Event::Key(Key::F(v - 12)), + v @ 11..=15 => Event::Key(Key::F(v - 10)), + v @ 17..=21 => Event::Key(Key::F(v - 11)), + v @ 23..=24 => Event::Key(Key::F(v - 12)), _ => return None, } } diff --git a/src/input.rs b/src/input.rs index 2d0aeb6..00f1a61 100644 --- a/src/input.rs +++ b/src/input.rs @@ -71,7 +71,7 @@ impl Iterator for EventsAndRaw { } } Ok(2) => { - let mut option_iter = &mut Some(buf[1]).into_iter(); + let option_iter = &mut Some(buf[1]).into_iter(); let result = { let mut iter = option_iter.map(|c| Ok(c)).chain(source.bytes()); parse_event(buf[0], &mut iter)