Skip to content

Commit

Permalink
Merge pull request #43 from sile/apply-cargo-fix
Browse files Browse the repository at this point in the history
Apply `cargo fix`
  • Loading branch information
sile committed Aug 19, 2019
2 parents 3ff53db + de4dbee commit 0170b0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions examples/flate.rs
Expand Up @@ -49,7 +49,7 @@ fn main() {
.get_matches();

let input_filename = matches.value_of("INPUT").unwrap();
let input: Box<io::Read> = if input_filename == "-" {
let input: Box<dyn io::Read> = if input_filename == "-" {
Box::new(io::stdin())
} else {
Box::new(
Expand All @@ -59,7 +59,7 @@ fn main() {
let mut input = io::BufReader::new(input);

let output_filename = matches.value_of("OUTPUT").unwrap();
let output: Box<io::Write> = if output_filename == "-" {
let output: Box<dyn io::Write> = if output_filename == "-" {
Box::new(io::stdout())
} else if output_filename == "/dev/null" {
Box::new(io::sink())
Expand Down
30 changes: 15 additions & 15 deletions src/deflate/symbol.rs
Expand Up @@ -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!(),
},
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -439,12 +439,12 @@ fn load_bitwidthes<R>(
reader: &mut bit::BitReader<R>,
code: u16,
last: Option<u8>,
) -> io::Result<Box<Iterator<Item = u8>>>
) -> io::Result<Box<dyn Iterator<Item = u8>>>
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"))?;
Expand Down

0 comments on commit 0170b0c

Please sign in to comment.