Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply cargo fix #43

Merged
merged 1 commit into from Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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