From de4dbee45e359f49b666b6e0c092208b5ade4fd6 Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Mon, 19 Aug 2019 17:25:09 +0900 Subject: [PATCH] Apply `cargo fix` --- examples/flate.rs | 4 ++-- src/deflate/symbol.rs | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/flate.rs b/examples/flate.rs index b490b98..2b0f21d 100644 --- a/examples/flate.rs +++ b/examples/flate.rs @@ -49,7 +49,7 @@ fn main() { .get_matches(); let input_filename = matches.value_of("INPUT").unwrap(); - let input: Box = if input_filename == "-" { + let input: Box = if input_filename == "-" { Box::new(io::stdin()) } else { Box::new( @@ -59,7 +59,7 @@ fn main() { let mut input = io::BufReader::new(input); let output_filename = matches.value_of("OUTPUT").unwrap(); - let output: Box = if output_filename == "-" { + let output: Box = if output_filename == "-" { Box::new(io::stdout()) } else if output_filename == "/dev/null" { Box::new(io::sink()) diff --git a/src/deflate/symbol.rs b/src/deflate/symbol.rs index 54e169a..61e7494 100644 --- a/src/deflate/symbol.rs +++ b/src/deflate/symbol.rs @@ -99,12 +99,12 @@ impl Symbol { Symbol::Literal(b) => u16::from(b), Symbol::EndOfBlock => 256, Symbol::Share { length, .. } => match length { - 3...10 => 257 + length - 3, - 11...18 => 265 + (length - 11) / 2, - 19...34 => 269 + (length - 19) / 4, - 35...66 => 273 + (length - 35) / 8, - 67...130 => 277 + (length - 67) / 16, - 131...257 => 281 + (length - 131) / 32, + 3..=10 => 257 + length - 3, + 11..=18 => 265 + (length - 11) / 2, + 19..=34 => 269 + (length - 19) / 4, + 35..=66 => 273 + (length - 35) / 8, + 67..=130 => 277 + (length - 67) / 16, + 131..=257 => 281 + (length - 131) / 32, 258 => 285, _ => unreachable!(), }, @@ -113,12 +113,12 @@ impl Symbol { pub fn extra_lengh(&self) -> Option<(u8, u16)> { if let Symbol::Share { length, .. } = *self { match length { - 3...10 | 258 => None, - 11...18 => Some((1, (length - 11) % 2)), - 19...34 => Some((2, (length - 19) % 4)), - 35...66 => Some((3, (length - 35) % 8)), - 67...130 => Some((4, (length - 67) % 16)), - 131...257 => Some((5, (length - 131) % 32)), + 3..=10 | 258 => None, + 11..=18 => Some((1, (length - 11) % 2)), + 19..=34 => Some((2, (length - 19) % 4)), + 35..=66 => Some((3, (length - 35) % 8)), + 67..=130 => Some((4, (length - 67) % 16)), + 131..=257 => Some((5, (length - 131) % 32)), _ => unreachable!(), } } else { @@ -203,7 +203,7 @@ impl Decoder { { let decoded = self.literal.decode_unchecked(reader); match decoded { - 0...255 => Symbol::Literal(decoded as u8), + 0..=255 => Symbol::Literal(decoded as u8), 256 => Symbol::EndOfBlock, 286 | 287 => { let message = format!("The value {} must not occur in compressed data", decoded); @@ -439,12 +439,12 @@ fn load_bitwidthes( reader: &mut bit::BitReader, code: u16, last: Option, -) -> io::Result>> +) -> io::Result>> where R: io::Read, { Ok(match code { - 0...15 => Box::new(iter::once(code as u8)), + 0..=15 => Box::new(iter::once(code as u8)), 16 => { let count = reader.read_bits(2)? + 3; let last = last.ok_or_else(|| invalid_data_error!("No preceding value"))?;