From d1d8f88fd6e799a216a69acd91e9a7edfec6c54f Mon Sep 17 00:00:00 2001 From: SimonVandeVyver Date: Thu, 12 Sep 2024 16:22:17 +0200 Subject: [PATCH] cargo fmt to format code --- bitarray/src/binary.rs | 11 +-- bitarray/src/lib.rs | 81 +++++++++------------ fa-compression/benches/algorithm1/decode.rs | 2 +- fa-compression/benches/algorithm1/encode.rs | 2 +- fa-compression/benches/algorithm2/decode.rs | 2 +- fa-compression/benches/algorithm2/encode.rs | 2 +- fa-compression/benches/util.rs | 2 +- fa-compression/src/algorithm1/encode.rs | 21 +++--- fa-compression/src/algorithm1/mod.rs | 8 +- fa-compression/src/algorithm2/encode.rs | 7 +- fa-compression/src/algorithm2/mod.rs | 4 +- libsais64-rs/builder.rs | 8 +- libsais64-rs/src/lib.rs | 6 +- sa-builder/src/lib.rs | 10 +-- sa-builder/src/main.rs | 4 +- sa-compression/src/lib.rs | 27 +++---- sa-index/src/binary.rs | 36 ++++----- sa-index/src/lib.rs | 10 +-- sa-index/src/peptide_search.rs | 18 ++--- sa-index/src/sa_searcher.rs | 58 +++++++-------- sa-index/src/suffix_to_protein_index.rs | 14 ++-- sa-mappings/src/proteins.rs | 16 ++-- sa-server/src/main.rs | 12 +-- text-compression/src/lib.rs | 31 ++++---- 24 files changed, 177 insertions(+), 215 deletions(-) diff --git a/bitarray/src/binary.rs b/bitarray/src/binary.rs index 4ab535f..a8084d1 100644 --- a/bitarray/src/binary.rs +++ b/bitarray/src/binary.rs @@ -167,13 +167,10 @@ mod tests { let mut buffer = Vec::new(); bitarray.write_binary(&mut buffer).unwrap(); - assert_eq!( - buffer, - vec![ - 0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x56, 0x34, 0x12, 0xf0 - ] - ); + assert_eq!(buffer, vec![ + 0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x56, 0x34, 0x12, 0xf0 + ]); } #[test] diff --git a/bitarray/src/lib.rs b/bitarray/src/lib.rs index d58a60c..e4bd8a2 100644 --- a/bitarray/src/lib.rs +++ b/bitarray/src/lib.rs @@ -4,7 +4,7 @@ mod binary; use std::{ cmp::max, - io::{Result, Write}, + io::{Result, Write} }; /// Re-export the `Binary` trait. @@ -19,7 +19,7 @@ pub struct BitArray { /// The length of the bit array. len: usize, /// The number of bits in a single element of the data vector. - bits_per_value: usize, + bits_per_value: usize } impl BitArray { @@ -39,7 +39,7 @@ impl BitArray { data: vec![0; capacity * bits_per_value / 64 + extra], mask: (1 << bits_per_value) - 1, len: capacity, - bits_per_value, + bits_per_value } } @@ -167,7 +167,7 @@ pub fn data_to_writer( data: Vec, bits_per_value: usize, max_capacity: usize, - writer: &mut impl Write, + writer: &mut impl Write ) -> Result<()> { // Update the max capacity to be a multiple of the greatest common divisor of the bits per value // and 64. This is done to ensure that the bit array can store the data entirely @@ -311,13 +311,10 @@ mod tests { data_to_writer(data, 40, 2, &mut writer).unwrap(); - assert_eq!( - writer, - vec![ - 0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x56, 0x34, 0x12, 0xf0 - ] - ); + assert_eq!(writer, vec![ + 0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x56, 0x34, 0x12, 0xf0 + ]); } #[test] @@ -336,27 +333,23 @@ mod tests { data_to_writer(data, 32, 8, &mut writer).unwrap(); - assert_eq!( - writer, - vec![ - 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, - 0x66, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, - 0xaa, 0xaa, 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, - 0xee, 0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, - 0x11, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x66, 0x55, - 0x55, 0x55, 0x55, 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0x99, - 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, - 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, - 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x88, - 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, - 0xcc, 0xcc, 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x44, - 0x33, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x88, 0x88, 0x88, 0x88, 0x77, - 0x77, 0x77, 0x77, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, 0xbb, 0xbb, - 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, - 0xff - ] - ); + assert_eq!(writer, vec![ + 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, 0x66, + 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, 0xaa, 0xaa, + 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, 0xdd, 0xdd, + 0xdd, 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, + 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x88, 0x88, + 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, + 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, + 0x66, 0x66, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, + 0xaa, 0xaa, 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, + 0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, + 0x11, 0x11, 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, + 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, + 0xcc, 0xcc, 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff + ]); } #[test] @@ -371,20 +364,16 @@ mod tests { data_to_writer(data, 32, 8, &mut writer).unwrap(); - assert_eq!( - writer, - vec![ - 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, - 0x66, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, - 0xaa, 0xaa, 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, - 0xee, 0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, - 0x11, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x66, 0x55, - 0x55, 0x55, 0x55, 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0x99, - 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, - 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, - 0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33 - ] - ); + assert_eq!(writer, vec![ + 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, 0x66, + 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, 0xaa, 0xaa, + 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, 0xdd, 0xdd, + 0xdd, 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, + 0x44, 0x44, 0x44, 0x44, 0x33, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x88, 0x88, + 0x88, 0x88, 0x77, 0x77, 0x77, 0x77, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0x99, 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xcc, + 0xbb, 0xbb, 0xbb, 0xbb, 0xee, 0xee, 0xee, 0xee, 0xdd, 0xdd, 0xdd, 0xdd, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33 + ]); } #[test] diff --git a/fa-compression/benches/algorithm1/decode.rs b/fa-compression/benches/algorithm1/decode.rs index bd1c94d..24991dc 100644 --- a/fa-compression/benches/algorithm1/decode.rs +++ b/fa-compression/benches/algorithm1/decode.rs @@ -22,7 +22,7 @@ pub fn decode_benchmark(c: &mut criterion::Criterion) { b.iter_batched( || generate_encoded_annotations(100), |annotations| black_box(decode(annotations.as_slice())), - criterion::BatchSize::SmallInput, + criterion::BatchSize::SmallInput ) }); } diff --git a/fa-compression/benches/algorithm1/encode.rs b/fa-compression/benches/algorithm1/encode.rs index 1d23a6e..d3a9c86 100644 --- a/fa-compression/benches/algorithm1/encode.rs +++ b/fa-compression/benches/algorithm1/encode.rs @@ -22,7 +22,7 @@ pub fn encode_benchmark(c: &mut criterion::Criterion) { b.iter_batched( || generate_decoded_annotations(100), |annotations| black_box(encode(annotations.as_str())), - criterion::BatchSize::SmallInput, + criterion::BatchSize::SmallInput ) }); } diff --git a/fa-compression/benches/algorithm2/decode.rs b/fa-compression/benches/algorithm2/decode.rs index 62f8b9e..4d562fc 100644 --- a/fa-compression/benches/algorithm2/decode.rs +++ b/fa-compression/benches/algorithm2/decode.rs @@ -28,7 +28,7 @@ pub fn decode_benchmark(c: &mut criterion::Criterion) { b.iter_batched( || generate_encoded_annotations_and_table(100), |(annotations, ct)| black_box(decode(annotations.as_slice(), ct)), - criterion::BatchSize::SmallInput, + criterion::BatchSize::SmallInput ) }); } diff --git a/fa-compression/benches/algorithm2/encode.rs b/fa-compression/benches/algorithm2/encode.rs index a69ed0e..827dd50 100644 --- a/fa-compression/benches/algorithm2/encode.rs +++ b/fa-compression/benches/algorithm2/encode.rs @@ -26,7 +26,7 @@ pub fn encode_benchmark(c: &mut criterion::Criterion) { b.iter_batched( || generate_decoded_annotations_and_table(100), |(annotations, ct)| black_box(encode(annotations.as_str(), ct)), - criterion::BatchSize::SmallInput, + criterion::BatchSize::SmallInput ) }); } diff --git a/fa-compression/benches/util.rs b/fa-compression/benches/util.rs index 0e80765..b6ddd9a 100644 --- a/fa-compression/benches/util.rs +++ b/fa-compression/benches/util.rs @@ -27,6 +27,6 @@ pub fn generate_annotation(random: &mut ThreadRng) -> String { 0 => generate_ipr(random), 1 => generate_go(random), 2 => generate_ec(random), - _ => unreachable!(), + _ => unreachable!() } } diff --git a/fa-compression/src/algorithm1/encode.rs b/fa-compression/src/algorithm1/encode.rs index 9138be1..ef79372 100644 --- a/fa-compression/src/algorithm1/encode.rs +++ b/fa-compression/src/algorithm1/encode.rs @@ -106,18 +106,16 @@ mod tests { #[test] fn test_encode_no_ec() { - assert_eq!( - encode("IPR:IPR016364;GO:0009279;IPR:IPR008816"), - vec![225, 17, 163, 138, 225, 39, 71, 95, 17, 153, 39] - ) + assert_eq!(encode("IPR:IPR016364;GO:0009279;IPR:IPR008816"), vec![ + 225, 17, 163, 138, 225, 39, 71, 95, 17, 153, 39 + ]) } #[test] fn test_encode_no_go() { - assert_eq!( - encode("IPR:IPR016364;EC:1.1.1.-;EC:1.2.1.7"), - vec![44, 44, 44, 191, 44, 60, 44, 142, 225, 39, 71, 80] - ) + assert_eq!(encode("IPR:IPR016364;EC:1.1.1.-;EC:1.2.1.7"), vec![ + 44, 44, 44, 191, 44, 60, 44, 142, 225, 39, 71, 80 + ]) } #[test] @@ -127,9 +125,8 @@ mod tests { #[test] fn test_encode_all() { - assert_eq!( - encode("IPR:IPR016364;EC:1.1.1.-;IPR:IPR032635;GO:0009279;IPR:IPR008816"), - vec![44, 44, 44, 190, 17, 26, 56, 174, 18, 116, 117, 241, 67, 116, 111, 17, 153, 39] - ) + assert_eq!(encode("IPR:IPR016364;EC:1.1.1.-;IPR:IPR032635;GO:0009279;IPR:IPR008816"), vec![ + 44, 44, 44, 190, 17, 26, 56, 174, 18, 116, 117, 241, 67, 116, 111, 17, 153, 39 + ]) } } diff --git a/fa-compression/src/algorithm1/mod.rs b/fa-compression/src/algorithm1/mod.rs index 8ea45c5..cdf7283 100644 --- a/fa-compression/src/algorithm1/mod.rs +++ b/fa-compression/src/algorithm1/mod.rs @@ -79,7 +79,7 @@ enum CharacterSet { Comma, /// Annotation separator - Semicolon, + Semicolon } impl Encode for CharacterSet { @@ -110,7 +110,7 @@ impl Encode for CharacterSet { b'n' => CharacterSet::Preliminary, b',' => CharacterSet::Comma, b';' => CharacterSet::Semicolon, - _ => panic!("Invalid character"), + _ => panic!("Invalid character") } } } @@ -143,7 +143,7 @@ impl Decode for CharacterSet { 13 => 'n', 14 => ',', 15 => ';', - _ => panic!("Invalid character"), + _ => panic!("Invalid character") } } } @@ -189,7 +189,7 @@ mod tests { CharacterSet::Point, CharacterSet::Preliminary, CharacterSet::Comma, - CharacterSet::Semicolon, + CharacterSet::Semicolon ]; #[test] diff --git a/fa-compression/src/algorithm2/encode.rs b/fa-compression/src/algorithm2/encode.rs index d60fe61..f55eb11 100644 --- a/fa-compression/src/algorithm2/encode.rs +++ b/fa-compression/src/algorithm2/encode.rs @@ -89,9 +89,8 @@ mod tests { #[test] fn test_encode_all() { let table = create_compresion_table(); - assert_eq!( - encode("IPR:IPR000001;EC:1.1.1.-;IPR:IPR000003;GO:0000002", table), - vec![0, 0, 0, 7, 0, 0, 2, 0, 0, 5, 0, 0] - ) + assert_eq!(encode("IPR:IPR000001;EC:1.1.1.-;IPR:IPR000003;GO:0000002", table), vec![ + 0, 0, 0, 7, 0, 0, 2, 0, 0, 5, 0, 0 + ]) } } diff --git a/fa-compression/src/algorithm2/mod.rs b/fa-compression/src/algorithm2/mod.rs index 117b87c..8fc505a 100644 --- a/fa-compression/src/algorithm2/mod.rs +++ b/fa-compression/src/algorithm2/mod.rs @@ -12,13 +12,13 @@ pub use encode::encode; /// Represents an entry in the compression table. #[doc(hidden)] pub struct CompressionTableEntry { - annotation: String, + annotation: String } /// Represents a compression table. pub struct CompressionTable { /// List of annotations in the compression table. - entries: Vec, + entries: Vec } impl CompressionTable { diff --git a/libsais64-rs/builder.rs b/libsais64-rs/builder.rs index c6fc2d6..5b3feb2 100644 --- a/libsais64-rs/builder.rs +++ b/libsais64-rs/builder.rs @@ -3,14 +3,14 @@ use std::{ error::Error, fmt::{Display, Formatter}, path::{Path, PathBuf}, - process::{Command, ExitStatus}, + process::{Command, ExitStatus} }; /// Custom error for compilation of the C library #[derive(Debug)] struct CompileError<'a> { command: &'a str, - exit_code: Option, + exit_code: Option } impl<'a> Display for CompileError<'a> { @@ -43,7 +43,7 @@ impl<'a> Error for CompileError<'a> {} fn exit_status_to_result(name: &str, exit_status: ExitStatus) -> Result<(), CompileError> { match exit_status.success() { true => Ok(()), - false => Err(CompileError { command: name, exit_code: exit_status.code() }), + false => Err(CompileError { command: name, exit_code: exit_status.code() }) } } @@ -61,7 +61,7 @@ fn main() -> Result<(), Box> { Command::new("rm").args(["libsais/CMakeCache.txt"]).status().unwrap_or_default(); // if removing fails, it is since the cmake cache did not exist, we just can ignore it exit_status_to_result( "cmake", - Command::new("cmake").args(["-DCMAKE_BUILD_TYPE=\"Release\"", "libsais", "-Blibsais"]).status()?, + Command::new("cmake").args(["-DCMAKE_BUILD_TYPE=\"Release\"", "libsais", "-Blibsais"]).status()? )?; exit_status_to_result("make", Command::new("make").args(["-C", "libsais"]).status()?)?; diff --git a/libsais64-rs/src/lib.rs b/libsais64-rs/src/lib.rs index b2a1d3a..e2a87f6 100644 --- a/libsais64-rs/src/lib.rs +++ b/libsais64-rs/src/lib.rs @@ -16,11 +16,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs")); pub fn sais64(text: &[u8]) -> Option> { let mut sa = vec![0; text.len()]; let exit_code = unsafe { libsais64(text.as_ptr(), sa.as_mut_ptr(), text.len() as i64, 0, std::ptr::null_mut()) }; - if exit_code == 0 { - Some(sa) - } else { - None - } + if exit_code == 0 { Some(sa) } else { None } } #[cfg(test)] diff --git a/sa-builder/src/lib.rs b/sa-builder/src/lib.rs index f20ec27..c0e13cd 100644 --- a/sa-builder/src/lib.rs +++ b/sa-builder/src/lib.rs @@ -21,14 +21,14 @@ pub struct Arguments { pub construction_algorithm: SAConstructionAlgorithm, /// If the suffix array should be compressed (default value true) #[arg(short, long, default_value_t = false)] - pub compress_sa: bool, + pub compress_sa: bool } /// Enum representing the two possible algorithms to construct the suffix array #[derive(ValueEnum, Clone, Debug, PartialEq)] pub enum SAConstructionAlgorithm { LibDivSufSort, - LibSais, + LibSais } /// Build a sparse suffix array from the given text @@ -48,7 +48,7 @@ pub enum SAConstructionAlgorithm { pub fn build_ssa( text: &mut Vec, construction_algorithm: &SAConstructionAlgorithm, - sparseness_factor: u8, + sparseness_factor: u8 ) -> Result, Box> { // translate all L's to a I translate_l_to_i(text); @@ -56,7 +56,7 @@ pub fn build_ssa( // Build the suffix array using the selected algorithm let mut sa = match construction_algorithm { SAConstructionAlgorithm::LibSais => libsais64_rs::sais64(text), - SAConstructionAlgorithm::LibDivSufSort => libdivsufsort_rs::divsufsort64(text), + SAConstructionAlgorithm::LibDivSufSort => libdivsufsort_rs::divsufsort64(text) } .ok_or("Building suffix array failed")?; @@ -125,7 +125,7 @@ mod tests { "2", "--construction-algorithm", "lib-div-suf-sort", - "--compress-sa", + "--compress-sa" ]); assert_eq!(args.database_file, "database.fa"); diff --git a/sa-builder/src/main.rs b/sa-builder/src/main.rs index 20f2e8a..01cc3c4 100644 --- a/sa-builder/src/main.rs +++ b/sa-builder/src/main.rs @@ -1,7 +1,7 @@ use std::{ fs::{File, OpenOptions}, io::BufWriter, - time::{SystemTime, SystemTimeError, UNIX_EPOCH}, + time::{SystemTime, SystemTimeError, UNIX_EPOCH} }; use clap::Parser; @@ -16,7 +16,7 @@ fn main() { output, sparseness_factor, construction_algorithm, - compress_sa, + compress_sa } = Arguments::parse(); eprintln!(); eprintln!("📋 Started loading the proteins..."); diff --git a/sa-compression/src/lib.rs b/sa-compression/src/lib.rs index 9814e20..e9952a2 100644 --- a/sa-compression/src/lib.rs +++ b/sa-compression/src/lib.rs @@ -1,6 +1,6 @@ use std::{ error::Error, - io::{BufRead, Write}, + io::{BufRead, Write} }; use bitarray::{data_to_writer, Binary, BitArray}; @@ -22,7 +22,7 @@ pub fn dump_compressed_suffix_array( sa: Vec, sparseness_factor: u8, bits_per_value: usize, - writer: &mut impl Write, + writer: &mut impl Write ) -> Result<(), Box> { // Write the flags to the writer // 00000001 indicates that the suffix array is compressed @@ -59,7 +59,7 @@ pub fn dump_compressed_suffix_array( /// Returns an error if reading from the reader fails. pub fn load_compressed_suffix_array( reader: &mut impl BufRead, - bits_per_value: usize, + bits_per_value: usize ) -> Result> { // Read the sample rate from the binary file (1 byte) let mut sample_rate_buffer = [0_u8; 1]; @@ -92,7 +92,7 @@ mod tests { pub struct FailingWriter { /// The number of times the write function can be called before it fails. - pub valid_write_count: usize, + pub valid_write_count: usize } impl Write for FailingWriter { @@ -112,7 +112,7 @@ mod tests { pub struct FailingReader { /// The number of times the read function can be called before it fails. - pub valid_read_count: usize, + pub valid_read_count: usize } impl Read for FailingReader { @@ -141,16 +141,13 @@ mod tests { let mut writer = vec![]; dump_compressed_suffix_array(sa, 1, 8, &mut writer).unwrap(); - assert_eq!( - writer, - vec![ - // bits per value - 8, // sparseness factor - 1, // size of the suffix array - 10, 0, 0, 0, 0, 0, 0, 0, // compressed suffix array - 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 10, 9 - ] - ); + assert_eq!(writer, vec![ + // bits per value + 8, // sparseness factor + 1, // size of the suffix array + 10, 0, 0, 0, 0, 0, 0, 0, // compressed suffix array + 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 10, 9 + ]); } #[test] diff --git a/sa-index/src/binary.rs b/sa-index/src/binary.rs index fc41f24..55c082a 100644 --- a/sa-index/src/binary.rs +++ b/sa-index/src/binary.rs @@ -1,6 +1,6 @@ use std::{ error::Error, - io::{BufRead, Read, Write}, + io::{BufRead, Read, Write} }; use crate::SuffixArray; @@ -190,7 +190,7 @@ mod tests { pub struct FailingWriter { /// The number of times the write function can be called before it fails. - pub valid_write_count: usize, + pub valid_write_count: usize } impl Write for FailingWriter { @@ -210,7 +210,7 @@ mod tests { pub struct FailingReader { /// The number of times the read function can be called before it fails. - pub valid_read_count: usize, + pub valid_read_count: usize } impl Read for FailingReader { @@ -266,13 +266,10 @@ mod tests { values.write_binary(&mut buffer).unwrap(); - assert_eq!( - buffer, - vec![ - 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5, 0, - 0, 0, 0, 0, 0, 0 - ] - ); + assert_eq!(buffer, vec![ + 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0 + ]); } #[test] @@ -295,17 +292,14 @@ mod tests { dump_suffix_array(&sa, 1, &mut buffer).unwrap(); - assert_eq!( - buffer, - vec![ - // required bits - 64, // Sparseness factor - 1, // Size of the suffix array - 5, 0, 0, 0, 0, 0, 0, 0, // Suffix array - 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5, 0, - 0, 0, 0, 0, 0, 0 - ] - ); + assert_eq!(buffer, vec![ + // required bits + 64, // Sparseness factor + 1, // Size of the suffix array + 5, 0, 0, 0, 0, 0, 0, 0, // Suffix array + 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0 + ]); } #[test] diff --git a/sa-index/src/lib.rs b/sa-index/src/lib.rs index a43168d..53f5348 100644 --- a/sa-index/src/lib.rs +++ b/sa-index/src/lib.rs @@ -10,7 +10,7 @@ pub enum SuffixArray { /// The original suffix array. Original(Vec, u8), /// The compressed suffix array. - Compressed(BitArray, u8), + Compressed(BitArray, u8) } impl SuffixArray { @@ -22,7 +22,7 @@ impl SuffixArray { pub fn len(&self) -> usize { match self { SuffixArray::Original(sa, _) => sa.len(), - SuffixArray::Compressed(sa, _) => sa.len(), + SuffixArray::Compressed(sa, _) => sa.len() } } @@ -34,7 +34,7 @@ impl SuffixArray { pub fn bits_per_value(&self) -> usize { match self { SuffixArray::Original(_, _) => 64, - SuffixArray::Compressed(sa, _) => sa.bits_per_value(), + SuffixArray::Compressed(sa, _) => sa.bits_per_value() } } @@ -46,7 +46,7 @@ impl SuffixArray { pub fn sample_rate(&self) -> u8 { match self { SuffixArray::Original(_, sample_rate) => *sample_rate, - SuffixArray::Compressed(_, sample_rate) => *sample_rate, + SuffixArray::Compressed(_, sample_rate) => *sample_rate } } @@ -62,7 +62,7 @@ impl SuffixArray { pub fn get(&self, index: usize) -> i64 { match self { SuffixArray::Original(sa, _) => sa[index], - SuffixArray::Compressed(sa, _) => sa.get(index) as i64, + SuffixArray::Compressed(sa, _) => sa.get(index) as i64 } } diff --git a/sa-index/src/peptide_search.rs b/sa-index/src/peptide_search.rs index 02e4975..55d629f 100644 --- a/sa-index/src/peptide_search.rs +++ b/sa-index/src/peptide_search.rs @@ -8,7 +8,7 @@ use crate::sa_searcher::{SearchAllSuffixesResult, Searcher}; pub struct SearchResult { pub sequence: String, pub proteins: Vec, - pub cutoff_used: bool, + pub cutoff_used: bool } /// Struct that represents all information known about a certain protein in our database @@ -16,7 +16,7 @@ pub struct SearchResult { pub struct ProteinInfo { pub taxon: u32, pub uniprot_accession: String, - pub functional_annotations: String, + pub functional_annotations: String } impl From<&Protein> for ProteinInfo { @@ -24,7 +24,7 @@ impl From<&Protein> for ProteinInfo { ProteinInfo { taxon: protein.taxon_id, uniprot_accession: protein.uniprot_id.clone(), - functional_annotations: protein.get_functional_annotations(), + functional_annotations: protein.get_functional_annotations() } } } @@ -50,7 +50,7 @@ pub fn search_proteins_for_peptide<'a>( searcher: &'a Searcher, peptide: &str, cutoff: usize, - equate_il: bool, + equate_il: bool ) -> Option<(bool, Vec<&'a Protein>)> { let peptide = peptide.trim_end().to_uppercase(); @@ -63,7 +63,7 @@ pub fn search_proteins_for_peptide<'a>( let (suffixes, cutoff_used) = match suffix_search { SearchAllSuffixesResult::MaxMatches(matched_suffixes) => Some((matched_suffixes, true)), SearchAllSuffixesResult::SearchResult(matched_suffixes) => Some((matched_suffixes, false)), - SearchAllSuffixesResult::NoMatches => None, + SearchAllSuffixesResult::NoMatches => None }?; let proteins = searcher.retrieve_proteins(&suffixes); @@ -77,7 +77,7 @@ pub fn search_peptide(searcher: &Searcher, peptide: &str, cutoff: usize, equate_ Some(SearchResult { sequence: peptide.to_string(), proteins: proteins.iter().map(|&protein| protein.into()).collect(), - cutoff_used, + cutoff_used }) } @@ -99,7 +99,7 @@ pub fn search_all_peptides( searcher: &Searcher, peptides: &Vec, cutoff: usize, - equate_il: bool, + equate_il: bool ) -> Vec { peptides .par_iter() @@ -123,7 +123,7 @@ mod tests { let protein_info = ProteinInfo { taxon: 1, uniprot_accession: "P12345".to_string(), - functional_annotations: "GO:0001234;GO:0005678".to_string(), + functional_annotations: "GO:0001234;GO:0005678".to_string() }; let generated_json = serde_json::to_string(&protein_info).unwrap(); @@ -138,7 +138,7 @@ mod tests { let search_result = SearchResult { sequence: "MSKIAALLPSV".to_string(), proteins: vec![], - cutoff_used: true, + cutoff_used: true }; let generated_json = serde_json::to_string(&search_result).unwrap(); diff --git a/sa-index/src/sa_searcher.rs b/sa-index/src/sa_searcher.rs index 119af6c..03abf07 100644 --- a/sa-index/src/sa_searcher.rs +++ b/sa-index/src/sa_searcher.rs @@ -6,21 +6,21 @@ use text_compression::ProteinTextSlice; use crate::{ sa_searcher::BoundSearch::{Maximum, Minimum}, suffix_to_protein_index::{DenseSuffixToProtein, SparseSuffixToProtein, SuffixToProteinIndex}, - Nullable, SuffixArray, + Nullable, SuffixArray }; /// Enum indicating if we are searching for the minimum, or maximum bound in the suffix array #[derive(Clone, Copy, PartialEq)] enum BoundSearch { Minimum, - Maximum, + Maximum } /// Enum representing the minimum and maximum bound of the found matches in the suffix array #[derive(PartialEq, Debug)] pub enum BoundSearchResult { NoMatches, - SearchResult((usize, usize)), + SearchResult((usize, usize)) } /// Enum representing the matching suffixes after searching a peptide in the suffix array @@ -30,7 +30,7 @@ pub enum BoundSearchResult { pub enum SearchAllSuffixesResult { NoMatches, MaxMatches(Vec), - SearchResult(Vec), + SearchResult(Vec) } /// Custom implementation of partialEq for SearchAllSuffixesResult @@ -67,7 +67,7 @@ impl PartialEq for SearchAllSuffixesResult { array_eq_unordered(arr1, arr2) } (SearchAllSuffixesResult::NoMatches, SearchAllSuffixesResult::NoMatches) => true, - _ => false, + _ => false } } } @@ -123,7 +123,7 @@ impl Deref for DenseSearcher { pub struct Searcher { pub sa: SuffixArray, pub proteins: Proteins, - pub suffix_index_to_protein: Box, + pub suffix_index_to_protein: Box } impl Searcher { @@ -172,7 +172,7 @@ impl Searcher { // Depending on if we are searching for the min of max bound our condition is different let condition_check = match bound { Minimum => |a: u8, b: u8| a < b, - Maximum => |a: u8, b: u8| a > b, + Maximum => |a: u8, b: u8| a > b }; // match as long as possible @@ -265,7 +265,7 @@ impl Searcher { match bound { Minimum => (found, right), - Maximum => (found, left), + Maximum => (found, left) } } @@ -307,7 +307,7 @@ impl Searcher { &self, search_string: &[u8], max_matches: usize, - equate_il: bool, + equate_il: bool ) -> SearchAllSuffixesResult { let mut matching_suffixes: Vec = vec![]; let mut il_locations = vec![]; @@ -394,13 +394,9 @@ impl Searcher { il_locations: &[usize], search_string: &[u8], text_slice: ProteinTextSlice, - equate_il: bool, + equate_il: bool ) -> bool { - if equate_il { - true - } else { - text_slice.check_il_locations(skip, il_locations, search_string) - } + if equate_il { true } else { text_slice.check_il_locations(skip, il_locations, search_string) } } /// Returns all the proteins that correspond with the provided suffixes @@ -432,7 +428,7 @@ mod tests { use crate::{ sa_searcher::{BoundSearchResult, SearchAllSuffixesResult, Searcher}, suffix_to_protein_index::SparseSuffixToProtein, - SuffixArray, + SuffixArray }; #[test] @@ -465,24 +461,24 @@ mod tests { Protein { uniprot_id: String::new(), taxon_id: 0, - functional_annotations: vec![], + functional_annotations: vec![] }, Protein { uniprot_id: String::new(), taxon_id: 0, - functional_annotations: vec![], + functional_annotations: vec![] }, Protein { uniprot_id: String::new(), taxon_id: 0, - functional_annotations: vec![], + functional_annotations: vec![] }, Protein { uniprot_id: String::new(), taxon_id: 0, - functional_annotations: vec![], + functional_annotations: vec![] }, - ], + ] } } @@ -568,8 +564,8 @@ mod tests { proteins: vec![Protein { uniprot_id: String::new(), taxon_id: 0, - functional_annotations: vec![], - }], + functional_annotations: vec![] + }] }; let sparse_sa = SuffixArray::Original(vec![0, 2, 4], 2); @@ -591,8 +587,8 @@ mod tests { proteins: vec![Protein { uniprot_id: String::new(), taxon_id: 0, - functional_annotations: vec![], - }], + functional_annotations: vec![] + }] }; let sparse_sa = SuffixArray::Original(vec![6, 0, 1, 5, 4, 3, 2], 1); @@ -613,8 +609,8 @@ mod tests { proteins: vec![Protein { uniprot_id: String::new(), taxon_id: 0, - functional_annotations: vec![], - }], + functional_annotations: vec![] + }] }; let sparse_sa = SuffixArray::Original(vec![6, 5, 4, 3, 2, 1, 0], 1); @@ -635,8 +631,8 @@ mod tests { proteins: vec![Protein { uniprot_id: String::new(), taxon_id: 0, - functional_annotations: vec![], - }], + functional_annotations: vec![] + }] }; let sparse_sa = SuffixArray::Original(vec![6, 4, 2, 0], 2); @@ -659,8 +655,8 @@ mod tests { proteins: vec![Protein { uniprot_id: String::new(), taxon_id: 0, - functional_annotations: vec![], - }], + functional_annotations: vec![] + }] }; let sparse_sa = SuffixArray::Original(vec![6, 5, 4, 3, 2, 1, 0], 1); diff --git a/sa-index/src/suffix_to_protein_index.rs b/sa-index/src/suffix_to_protein_index.rs index 1a224d2..a6a4e93 100644 --- a/sa-index/src/suffix_to_protein_index.rs +++ b/sa-index/src/suffix_to_protein_index.rs @@ -1,14 +1,14 @@ use clap::ValueEnum; use sa_mappings::proteins::{SEPARATION_CHARACTER, TERMINATION_CHARACTER}; +use text_compression::ProteinText; use crate::Nullable; -use text_compression::ProteinText; /// Enum used to define the commandline arguments and choose which index style is used #[derive(ValueEnum, Clone, Debug, PartialEq)] pub enum SuffixToProteinMappingStyle { Dense, - Sparse, + Sparse } /// Trait implemented by the SuffixToProtein mappings @@ -29,14 +29,14 @@ pub trait SuffixToProteinIndex: Send + Sync { #[derive(Debug, PartialEq)] pub struct DenseSuffixToProtein { // UniProtKB does not have more that u32::MAX proteins, so a larger type is not needed - mapping: Vec, + mapping: Vec } /// Mapping that uses O(m) memory with m the number of proteins, but retrieval of the protein is /// O(log m) #[derive(Debug, PartialEq)] pub struct SparseSuffixToProtein { - mapping: Vec, + mapping: Vec } impl SuffixToProteinIndex for DenseSuffixToProtein { @@ -113,9 +113,9 @@ mod tests { use crate::{ suffix_to_protein_index::{ - DenseSuffixToProtein, SparseSuffixToProtein, SuffixToProteinIndex, SuffixToProteinMappingStyle, + DenseSuffixToProtein, SparseSuffixToProtein, SuffixToProteinIndex, SuffixToProteinMappingStyle }, - Nullable, + Nullable }; fn build_text() -> ProteinText { @@ -138,7 +138,7 @@ mod tests { let u8_text = &build_text(); let index = DenseSuffixToProtein::new(u8_text); let expected = DenseSuffixToProtein { - mapping: vec![0, 0, 0, u32::NULL, 1, 1, u32::NULL, 2, 2, 2, u32::NULL], + mapping: vec![0, 0, 0, u32::NULL, 1, 1, u32::NULL, 2, 2, 2, u32::NULL] }; assert_eq!(index, expected); } diff --git a/sa-mappings/src/proteins.rs b/sa-mappings/src/proteins.rs index 9285980..53e52b8 100644 --- a/sa-mappings/src/proteins.rs +++ b/sa-mappings/src/proteins.rs @@ -23,7 +23,7 @@ pub struct Protein { pub taxon_id: u32, /// The encoded functional annotations of the protein - pub functional_annotations: Vec, + pub functional_annotations: Vec } /// A struct that represents a collection of proteins @@ -32,7 +32,7 @@ pub struct Proteins { pub text: ProteinText, /// The proteins in the input string - pub proteins: Vec, + pub proteins: Vec } impl Protein { @@ -80,7 +80,7 @@ impl Proteins { proteins.push(Protein { uniprot_id: uniprot_id.to_string(), taxon_id, - functional_annotations, + functional_annotations }); } @@ -195,7 +195,7 @@ mod tests { .unwrap(); file.write( "P13579\t17\tKEGILQYCQEVYPELQITNVVEANQPVTIQNWCKRGRKQCKTHPH\tGO:0009279;IPR:IPR016364;IPR:IPR008816\n" - .as_bytes(), + .as_bytes() ) .unwrap(); @@ -207,7 +207,7 @@ mod tests { let protein = Protein { uniprot_id: "P12345".to_string(), taxon_id: 1, - functional_annotations: vec![0xD1, 0x11], + functional_annotations: vec![0xD1, 0x11] }; assert_eq!(protein.uniprot_id, "P12345"); @@ -225,14 +225,14 @@ mod tests { Protein { uniprot_id: "P12345".to_string(), taxon_id: 1, - functional_annotations: vec![0xD1, 0x11], + functional_annotations: vec![0xD1, 0x11] }, Protein { uniprot_id: "P54321".to_string(), taxon_id: 2, - functional_annotations: vec![0xD1, 0x11], + functional_annotations: vec![0xD1, 0x11] }, - ], + ] }; assert_eq!(proteins.proteins.len(), 2); diff --git a/sa-server/src/main.rs b/sa-server/src/main.rs index c65ba7c..5284546 100644 --- a/sa-server/src/main.rs +++ b/sa-server/src/main.rs @@ -2,14 +2,14 @@ use std::{ error::Error, fs::File, io::{BufReader, Read}, - sync::Arc, + sync::Arc }; use axum::{ extract::{DefaultBodyLimit, State}, http::StatusCode, routing::post, - Json, Router, + Json, Router }; use clap::Parser; use sa_compression::load_compressed_suffix_array; @@ -17,7 +17,7 @@ use sa_index::{ binary::load_suffix_array, peptide_search::{search_all_peptides, SearchResult}, sa_searcher::SparseSearcher, - SuffixArray, + SuffixArray }; use sa_mappings::proteins::Proteins; use serde::Deserialize; @@ -30,7 +30,7 @@ pub struct Arguments { #[arg(short, long)] database_file: String, #[arg(short, long)] - index_file: String, + index_file: String } /// Function used by serde to place a default value in the cutoff field of the input @@ -58,7 +58,7 @@ struct InputData { cutoff: usize, #[serde(default = "bool::default")] // default value is false // TODO: maybe default should be true? - equate_il: bool, + equate_il: bool } #[tokio::main] @@ -81,7 +81,7 @@ async fn main() { /// Returns the search results from the index as a JSON async fn search( State(searcher): State>, - data: Json, + data: Json ) -> Result>, StatusCode> { let search_result = search_all_peptides(&searcher, &data.peptides, data.cutoff, data.equate_il); diff --git a/text-compression/src/lib.rs b/text-compression/src/lib.rs index dc7f71e..85e93b3 100644 --- a/text-compression/src/lib.rs +++ b/text-compression/src/lib.rs @@ -1,7 +1,7 @@ -use std::collections::HashMap; use std::{ + collections::HashMap, error::Error, - io::{BufRead, Write}, + io::{BufRead, Write} }; use bitarray::{data_to_writer, Binary, BitArray}; @@ -13,7 +13,7 @@ pub struct ProteinText { /// Hashmap storing the mapping between the character as `u8` and a 5 bit number. char_to_5bit: HashMap, /// Vector storing the mapping between the 5 bit number and the character as `u8`. - bit5_to_char: Vec, + bit5_to_char: Vec } impl ProteinText { @@ -184,7 +184,7 @@ pub struct ProteinTextSlice<'a> { /// The start of the slice. start: usize, // included /// The end of the slice. - end: usize, // excluded + end: usize // excluded } impl<'a> ProteinTextSlice<'a> { @@ -282,13 +282,13 @@ impl<'a> ProteinTextSlice<'a> { /// Structure representing an iterator over a `ProteinText` instance, iterating the characters of the text. pub struct ProteinTextIterator<'a> { protein_text: &'a ProteinText, - index: usize, + index: usize } /// Structure representing an iterator over a `ProteintextSlice` instance, iterating the characters of the slice. pub struct ProteinTextSliceIterator<'a> { text_slice: &'a ProteinTextSlice<'a>, - index: usize, + index: usize } impl<'a> Iterator for ProteinTextSliceIterator<'a> { @@ -394,7 +394,7 @@ mod tests { pub struct FailingWriter { /// The number of times the write function can be called before it fails. - pub valid_write_count: usize, + pub valid_write_count: usize } impl Write for FailingWriter { @@ -414,7 +414,7 @@ mod tests { pub struct FailingReader { /// The number of times the read function can be called before it fails. - pub valid_read_count: usize, + pub valid_read_count: usize } impl Read for FailingReader { @@ -545,15 +545,12 @@ mod tests { let mut writer = vec![]; dump_compressed_text(text, &mut writer).unwrap(); - assert_eq!( - writer, - vec![ - // bits per value - 5, // size of the text - 10, 0, 0, 0, 0, 0, 0, 0, // compressed text - 0, 128, 74, 232, 152, 66, 134, 8 - ] - ); + assert_eq!(writer, vec![ + // bits per value + 5, // size of the text + 10, 0, 0, 0, 0, 0, 0, 0, // compressed text + 0, 128, 74, 232, 152, 66, 134, 8 + ]); } #[test]