diff options
| author | Philipp Gesang <phg@phi-gamma.net> | 2021-11-10 00:41:31 +0100 | 
|---|---|---|
| committer | Philipp Gesang <phg@phi-gamma.net> | 2021-11-10 01:20:12 +0100 | 
| commit | fece719438908c58c9cff454d428279a8240c8af (patch) | |
| tree | 1f5b50cf98cb522fcfc290493be0c9fdd9c14685 /src | |
| parent | c1c902b4b534254b04bb0bd04c2c26a98103fa9f (diff) | |
| download | vtcol-fece719438908c58c9cff454d428279a8240c8af.tar.gz | |
apply some clippy lints
Diffstat (limited to 'src')
| -rw-r--r-- | src/vtcol.rs | 27 | 
1 files changed, 12 insertions, 15 deletions
diff --git a/src/vtcol.rs b/src/vtcol.rs index 3cae3f2..31ea9d9 100644 --- a/src/vtcol.rs +++ b/src/vtcol.rs @@ -357,7 +357,7 @@ impl Palette          for def in colors.iter() {              let (r, g, b) = rgb_of_hex_triplet(*def); -            pal[idx    ] = r; +            pal[idx] = r;              pal[idx + 1] = g;              pal[idx + 2] = b;              //println!(">> {} -> {:X} {:X} {:X}", def, r, g, b); @@ -389,12 +389,10 @@ impl Palette                          /* Palette index specified, number prepended */                          let parse_res: Result<usize, _> =                              std::str::FromStr::from_str(&line[0..off]); -                        match parse_res { -                            Ok(new_idx) => -                                if new_idx < PALETTE_SIZE { -                                    pal_idx = new_idx * 3; -                                }, -                            _ => (), +                        if let Ok(new_idx) = parse_res { +                            if new_idx < PALETTE_SIZE { +                                pal_idx = new_idx * 3; +                            }                          }                      }                      let off = off + 1; @@ -405,7 +403,7 @@ impl Palette                      let col = &line[off..(off + RAW_COLEXPR_SIZE)];                      let (r, g, b) = rgb_of_hex_triplet(col); -                    pal[pal_idx    ] = r; +                    pal[pal_idx] = r;                      pal[pal_idx + 1] = g;                      pal[pal_idx + 2] = b;                      pal_idx = (pal_idx + 3) % PALETTE_BYTES; @@ -456,7 +454,7 @@ impl fmt::Display for Palette          let mut i = 0;          while i < PALETTE_BYTES {              let _ = write!(f, "{}", if i == 0 { "(" } else { "\n " }); -            let r = self.colors[i    ]; +            let r = self.colors[i];              let g = self.colors[i + 1];              let b = self.colors[i + 2];              let _ = write!( @@ -476,13 +474,13 @@ impl fmt::Debug for Palette      {          let mut i: u8 = 0_u8;          while (i as usize) < PALETTE_BYTES { -            let r = self.colors[i as usize    ]; +            let r = self.colors[i as usize];              let g = self.colors[i as usize + 1];              let b = self.colors[i as usize + 2];              let _ = writeln!(                  f,                  "{} => 0x{:02.X}{:02.X}{:02.X}", -                Color::of_value(i).to_string(), +                Color::of_value(i),                  r,                  g,                  b @@ -497,7 +495,7 @@ fn fd_of_path(path: &std::path::Path) -> Option<Fd>  {      let p = std::ffi::CString::new(path.to_str().unwrap()).unwrap();      match unsafe { libc::open(p.as_ptr(), libc::O_RDWR | O_NOCTTY, 0) } { -        -1 => return None, +        -1 => None,          fd => {              vrb!("  *> got fd");              if unsafe { libc::isatty(fd) } == 0 { @@ -523,7 +521,7 @@ fn fd_of_path(path: &std::path::Path) -> Option<Fd>                  return None;              } -            return Some(fd); +            Some(fd)          },      }  } @@ -539,8 +537,7 @@ fn get_console_fd(path: Option<&str>) -> Option<Fd>              }          },          None => { -            let mut it = CONSOLE_PATHS.iter(); -            while let Some(path) = it.next() { +            for path in CONSOLE_PATHS.iter() {                  vrb!("trying path: {:?}", path);                  let path = std::path::Path::new(path);                  if let Some(fd) = fd_of_path(path) {  | 
