diff --git a/src/lib.rs b/src/lib.rs index 60f8813..ce6b519 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,7 +77,11 @@ pub struct ImagePair { impl ImagePair { /// Construct a new `ImagePair` from the given paths and original file size. - pub fn new(original: impl Into, decoded: impl Into, original_size: u64) -> Self { + pub fn new( + original: impl Into, + decoded: impl Into, + original_size: u64, + ) -> Self { Self { original: original.into(), decoded: decoded.into(), @@ -138,7 +142,14 @@ pub fn assign_split_by_index(index: usize, total: usize) -> Split { /// /// The partition is deterministic given a pre-ordered (e.g. shuffled) slice. /// Returns `(train, test, val, calibration)`. -pub fn partition_pairs(pairs: &[ImagePair]) -> (Vec<&ImagePair>, Vec<&ImagePair>, Vec<&ImagePair>, Vec<&ImagePair>) { +pub fn partition_pairs( + pairs: &[ImagePair], +) -> ( + Vec<&ImagePair>, + Vec<&ImagePair>, + Vec<&ImagePair>, + Vec<&ImagePair>, +) { let total = pairs.len(); let mut train = Vec::new(); let mut test = Vec::new(); diff --git a/tests/smoke_test.rs b/tests/smoke_test.rs index 99c598a..024d87e 100644 --- a/tests/smoke_test.rs +++ b/tests/smoke_test.rs @@ -75,7 +75,11 @@ fn split_all_contains_four_unique_variants() { // Verify there are no duplicates by comparing hash-equality. use std::collections::HashSet; let set: HashSet<_> = all.iter().collect(); - assert_eq!(set.len(), 4, "Split::all() must not contain duplicate variants"); + assert_eq!( + set.len(), + 4, + "Split::all() must not contain duplicate variants" + ); } // --------------------------------------------------------------------------- @@ -213,7 +217,10 @@ fn assign_split_by_index_single_item_documented_behaviour() { let split = assign_split_by_index(0, 1); // Must be a valid variant (no panic or undefined behaviour). assert!( - matches!(split, Split::Train | Split::Test | Split::Val | Split::Calibration), + matches!( + split, + Split::Train | Split::Test | Split::Val | Split::Calibration + ), "must return a valid Split for single-item dataset" ); } @@ -236,7 +243,13 @@ fn partition_pairs_empty_slice_produces_empty_vecs() { #[test] fn partition_pairs_total_count_equals_input_length() { let pairs: Vec = (0..200) - .map(|i| ImagePair::new(format!("orig/{}.png", i), format!("dec/{}.png", i), i as u64 * 1024)) + .map(|i| { + ImagePair::new( + format!("orig/{}.png", i), + format!("dec/{}.png", i), + i as u64 * 1024, + ) + }) .collect(); let (train, test, val, calibration) = partition_pairs(&pairs);