Fix clippy warnings (#533)

This commit is contained in:
Koxiaet 2021-01-02 14:24:34 +00:00 committed by GitHub
parent 6a1114b241
commit 6c0f8ebcf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 22 deletions

View File

@ -50,14 +50,10 @@ fn print_events() -> Result<()> {
fn flush_resize_events(event: Event) -> ((u16, u16), (u16, u16)) { fn flush_resize_events(event: Event) -> ((u16, u16), (u16, u16)) {
if let Event::Resize(x, y) = event { if let Event::Resize(x, y) = event {
let mut last_resize = (x, y); let mut last_resize = (x, y);
loop { while let Ok(true) = poll(Duration::from_millis(50)) {
if let Ok(true) = poll(Duration::from_millis(50)) {
if let Ok(Event::Resize(x, y)) = read() { if let Ok(Event::Resize(x, y)) = read() {
last_resize = (x, y); last_resize = (x, y);
} }
} else {
break;
}
} }
return ((x, y), last_resize); return ((x, y), last_resize);

View File

@ -156,7 +156,7 @@ pub(crate) fn parse_csi(buffer: &[u8]) -> Result<Option<InternalEvent>> {
// The final byte of a CSI sequence can be in the range 64-126, so // The final byte of a CSI sequence can be in the range 64-126, so
// let's keep reading anything else. // let's keep reading anything else.
let last_byte = *buffer.last().unwrap(); let last_byte = *buffer.last().unwrap();
if last_byte < 64 || last_byte > 126 { if !(64..=126).contains(&last_byte) {
None None
} else { } else {
match buffer[buffer.len() - 1] { match buffer[buffer.len() - 1] {

View File

@ -87,21 +87,18 @@ pub(crate) fn disable_raw_mode() -> Result<()> {
/// ///
/// The arg should be "cols" or "lines" /// The arg should be "cols" or "lines"
fn tput_value(arg: &str) -> Option<u16> { fn tput_value(arg: &str) -> Option<u16> {
match process::Command::new("tput").arg(arg).output() { let output = process::Command::new("tput").arg(arg).output().ok()?;
Ok(process::Output { stdout, .. }) => { let value = output
let value = stdout .stdout
.iter() .into_iter()
.map(|&b| b as u16) .filter_map(|b| char::from(b).to_digit(10))
.take_while(|&b| b >= 48 && b <= 58) .fold(0, |v, n| v * 10 + n as u16);
.fold(0, |v, b| v * 10 + (b - 48));
if value > 0 { if value > 0 {
Some(value) Some(value)
} else { } else {
None None
} }
}
_ => None,
}
} }
/// Returns the size of the screen as determined by tput. /// Returns the size of the screen as determined by tput.