Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Aug 15, 2024
1 parent 4fbbb99 commit 3b14e8d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions examples/file_compressor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(missing_docs)]
#![allow(missing_docs, clippy::use_debug)]

//! This is a command line program that expects two input files as arguments.
//!
Expand Down Expand Up @@ -44,8 +44,7 @@ fn main() {

let mut chunk_idx = 1;
let mut pos = 0;
let mut chunk = Vec::with_capacity(CHUNK_SIZE);
unsafe { chunk.set_len(CHUNK_SIZE) };
let mut chunk = vec![0u8; CHUNK_SIZE];
while pos + CHUNK_SIZE < size_bytes {
f.read_exact_at(&mut chunk, pos as u64).unwrap();
// Compress the chunk, don't write it anywhere.
Expand All @@ -60,8 +59,7 @@ fn main() {
// Read last chunk with a new custom-sized buffer.
if pos < size_bytes {
let amount = size_bytes - pos;
chunk = Vec::with_capacity(size_bytes - pos);
unsafe { chunk.set_len(amount) };
chunk = vec![0u8; size_bytes - pos];
f.read_exact_at(&mut chunk, pos as u64).unwrap();
// Compress the chunk, don't write it anywhere.
let compact = compressor.compress(&chunk[0..amount]);
Expand Down

0 comments on commit 3b14e8d

Please sign in to comment.