Skip to content

Commit

Permalink
refactor: improved code, removed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
m62624 committed Jul 7, 2024
1 parent 1060b43 commit bde780e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub mod data_chunk {
}

fn percentage_chunk(file_size: f64, ram_available: f64, percentage: f64) -> f64 {
(file_size * (percentage.min(100.0).max(0.1) / 100.0)).min(ram_available * 0.85)
(file_size * (percentage.clamp(0.1, 100.0) / 100.0)).min(ram_available * 0.85)
}

fn bytes_chunk(file_size: f64, ram_available: f64, bytes: usize) -> f64 {
Expand Down
3 changes: 1 addition & 2 deletions tests/iterator.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
mod temp_files;

use temp_files::{FileTest, FILE_TEST};

#[cfg(feature = "size_format")]
mod size_format {
use super::*;
use get_chunk::data_size_format::iec::{IECSize, IECUnit};
use get_chunk::iterator::FileIter;
use get_chunk::ChunkSize;
use std::io;
use temp_files::{FileTest, FILE_TEST};

mod set_mode_tests {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion tests/stream.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod temp_files;
use temp_files::{FileTest, FILE_TEST};

#[cfg(all(feature = "size_format", feature = "stream"))]
mod size_format {
Expand All @@ -8,6 +7,7 @@ mod size_format {
use get_chunk::stream::{FileStream, StreamExt, TryFrom};
use get_chunk::ChunkSize;
use std::io;
use temp_files::{FileTest, FILE_TEST};

mod set_mode_tests {
use super::*;
Expand Down

0 comments on commit bde780e

Please sign in to comment.