Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Jun 10, 2023
1 parent e9a0bcf commit b72e930
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(nightly, feature(optimize_attribute))]

#[allow(unused_imports)]
#[cfg_attr(test, macro_use)]
extern crate alloc;

Expand All @@ -96,13 +95,13 @@ mod fastcpy;
mod fastcpy_unsafe;

#[deprecated(
since = "0.11",
note = "This re-export is deprecated as it can be confused with the frame API, use block:: instead"
since = "0.11.0",
note = "This re-export is deprecated as it can be confused with the frame API and is not suitable for very large data, use block:: instead"
)]
pub use block::{compress, compress_into, compress_prepend_size};
#[deprecated(
since = "0.11",
note = "This re-export is deprecated as it can be confused with the frame API, use block:: instead"
since = "0.11.0",
note = "This re-export is deprecated as it can be confused with the frame API and is not suitable for very large data, use block:: instead"
)]
pub use block::{decompress, decompress_into, decompress_size_prepended};

Expand Down
14 changes: 7 additions & 7 deletions src/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::fastcpy::slice_copy;
/// when the `safe-decode` feature is enabled, or `VecSink` otherwise.
/// The argument `pos` defines the initial output position in the Sink.
#[inline]
#[cfg(any(feature = "frame"))]
#[cfg(feature = "frame")]
pub fn vec_sink_for_compression(
vec: &mut Vec<u8>,
offset: usize,
Expand Down Expand Up @@ -50,7 +50,7 @@ pub trait Sink {
fn byte_at(&mut self, pos: usize) -> u8;

/// Pushes a byte to the end of the Sink.
#[cfg(any(feature = "safe-encode"))]
#[cfg(feature = "safe-encode")]
fn push(&mut self, byte: u8);

#[cfg(not(all(feature = "safe-encode", feature = "safe-decode")))]
Expand All @@ -63,7 +63,7 @@ pub trait Sink {
#[cfg(not(all(feature = "safe-encode", feature = "safe-decode")))]
unsafe fn set_pos(&mut self, new_pos: usize);

#[cfg(any(feature = "safe-decode"))]
#[cfg(feature = "safe-decode")]
fn extend_with_fill(&mut self, byte: u8, len: usize);

/// Extends the Sink with `data`.
Expand Down Expand Up @@ -126,7 +126,7 @@ impl<'a> Sink for SliceSink<'a> {

/// Pushes a byte to the end of the Sink.
#[inline]
#[cfg(any(feature = "safe-encode"))]
#[cfg(feature = "safe-encode")]
fn push(&mut self, byte: u8) {
self.output[self.pos] = byte;
self.pos += 1;
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<'a> Sink for SliceSink<'a> {
}

#[inline]
#[cfg(any(feature = "safe-decode"))]
#[cfg(feature = "safe-decode")]
fn extend_with_fill(&mut self, byte: u8, len: usize) {
self.output[self.pos..self.pos + len].fill(byte);
self.pos += len;
Expand Down Expand Up @@ -245,7 +245,7 @@ impl Sink for PtrSink {

/// Pushes a byte to the end of the Sink.
#[inline]
#[cfg(any(feature = "safe-encode"))]
#[cfg(feature = "safe-encode")]
fn push(&mut self, byte: u8) {
unsafe {
self.pos_mut_ptr().write(byte);
Expand Down Expand Up @@ -276,7 +276,7 @@ impl Sink for PtrSink {
}

#[inline]
#[cfg(any(feature = "safe-decode"))]
#[cfg(feature = "safe-decode")]
fn extend_with_fill(&mut self, _byte: u8, _len: usize) {
unreachable!();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const COMPRESSION34K: &[u8] = include_bytes!("../benches/compression_34k.txt");
const COMPRESSION65: &[u8] = include_bytes!("../benches/compression_65k.txt");
const COMPRESSION66JSON: &[u8] = include_bytes!("../benches/compression_66k_JSON.txt");
const COMPRESSION10MB: &[u8] = include_bytes!("../benches/dickens.txt");
const DECOMPRESSION10MB: &[u8] = include_bytes!("../benches/dickens.lz4");

fn lz4_cpp_block_compress(input: &[u8]) -> Result<Vec<u8>, lzzzz::Error> {
let mut out = Vec::new();
Expand Down Expand Up @@ -748,7 +747,8 @@ mod frame {
#[test]
#[cfg_attr(miri, ignore)]
fn legacy_frame() {
let uncompressed = lz4_flex_frame_decompress(DECOMPRESSION10MB).unwrap();
const DECOMPRESSION10MB_LEGACY: &[u8] = include_bytes!("../benches/dickens.lz4");
let uncompressed = lz4_flex_frame_decompress(DECOMPRESSION10MB_LEGACY).unwrap();
assert_eq!(uncompressed, COMPRESSION10MB);
}
}
Expand Down

0 comments on commit b72e930

Please sign in to comment.