Skip to content

Commit

Permalink
fix nightly, clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Mar 19, 2024
1 parent 4e87de7 commit ccf4f0f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/block/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ use crate::sink::Sink;
use crate::sink::SliceSink;
#[allow(unused_imports)]
use alloc::vec;
use alloc::vec::Vec;

#[cfg(feature = "safe-encode")]
use core::convert::TryInto;
#[allow(unused_imports)]
use alloc::vec::Vec;

use super::hashtable::HashTable4K;
use super::hashtable::HashTable4KU16;
Expand Down
5 changes: 3 additions & 2 deletions src/block/decompress_safe.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! The block decompression algorithm.
use core::convert::TryInto;

use crate::block::DecompressError;
use crate::block::MINMATCH;
use crate::sink::Sink;
use crate::sink::SliceSink;

#[allow(unused_imports)]
use alloc::vec;
#[allow(unused_imports)]
use alloc::vec::Vec;

/// Read an integer.
Expand Down
2 changes: 1 addition & 1 deletion src/block/hashtable.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use alloc::boxed::Box;
use core::convert::TryInto;

/// The Hashtable trait used by the compression to store hashed bytes to their position.
/// `val` can be maximum the size of the input in bytes.
Expand Down Expand Up @@ -36,6 +35,7 @@ fn hash5(sequence: usize) -> u32 {
pub trait HashTable {
fn get_at(&self, pos: usize) -> usize;
fn put_at(&mut self, pos: usize, val: usize);
#[allow(dead_code)]
fn clear(&mut self);
#[inline]
#[cfg(target_pointer_width = "64")]
Expand Down
1 change: 0 additions & 1 deletion src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pub(crate) mod decompress;
pub use compress::*;
pub use decompress::*;

use core::convert::TryInto;
use core::fmt;

pub(crate) const WINDOW_SIZE: usize = 64 * 1024;
Expand Down
5 changes: 2 additions & 3 deletions src/frame/decompress.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
convert::TryInto,
fmt,
hash::Hasher,
io::{self, BufRead, ErrorKind},
Expand Down Expand Up @@ -371,7 +370,7 @@ impl<R: io::Read> io::Read for FrameDecoder<R> {
let mut written = 0;
loop {
match self.fill_buf() {
Ok(b) if b.is_empty() => return Ok(written),
Ok([]) => return Ok(written),

Check warning on line 373 in src/frame/decompress.rs

View check run for this annotation

Codecov / codecov/patch

src/frame/decompress.rs#L373

Added line #L373 was not covered by tests
Ok(b) => {
let s = std::str::from_utf8(b).map_err(|_| {
io::Error::new(
Expand All @@ -394,7 +393,7 @@ impl<R: io::Read> io::Read for FrameDecoder<R> {
let mut written = 0;
loop {
match self.fill_buf() {
Ok(b) if b.is_empty() => return Ok(written),
Ok([]) => return Ok(written),
Ok(b) => {
buf.extend_from_slice(b);
let len = b.len();
Expand Down
1 change: 0 additions & 1 deletion src/frame/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use twox_hash::XxHash32;

use super::Error;
use std::{
convert::TryInto,
fmt::Debug,
hash::Hasher,
io,
Expand Down
9 changes: 5 additions & 4 deletions src/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ pub fn vec_sink_for_compression(
pos: usize,
required_capacity: usize,
) -> SliceSink {
return {
{
vec.resize(offset + required_capacity, 0);
SliceSink::new(&mut vec[offset..], pos)
};
}
}

/// Returns a Sink implementation appropriate for outputing up to `required_capacity`
Expand All @@ -35,10 +35,10 @@ pub fn vec_sink_for_decompression(
pos: usize,
required_capacity: usize,
) -> SliceSink {
return {
{
vec.resize(offset + required_capacity, 0);
SliceSink::new(&mut vec[offset..], pos)
};
}
}

pub trait Sink {
Expand All @@ -47,6 +47,7 @@ pub trait Sink {
unsafe fn pos_mut_ptr(&mut self) -> *mut u8;

/// read byte at position
#[allow(dead_code)]
fn byte_at(&mut self, pos: usize) -> u8;

/// Pushes a byte to the end of the Sink.
Expand Down

0 comments on commit ccf4f0f

Please sign in to comment.