From 64277d06dfa259fd92acad309bad3726e8752d14 Mon Sep 17 00:00:00 2001 From: tibvdm Date: Mon, 8 Apr 2024 10:02:39 +0200 Subject: [PATCH] formatting --- fa-compression/src/algorithm2/decode.rs | 2 +- fa-compression/src/algorithm2/encode.rs | 6 ++--- fa-compression/src/algorithm2/mod.rs | 34 ++++++++++++++----------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/fa-compression/src/algorithm2/decode.rs b/fa-compression/src/algorithm2/decode.rs index 438b637..3835d01 100644 --- a/fa-compression/src/algorithm2/decode.rs +++ b/fa-compression/src/algorithm2/decode.rs @@ -24,7 +24,7 @@ use super::CompressionTable; /// let mut compression_table = CompressionTable::new(); /// compression_table.add_entry("IPR:IPR000001".to_string()); /// compression_table.add_entry("IPR:IPR000002".to_string()); -/// +/// /// let decoded_string = decode(input, compression_table); /// assert_eq!(decoded_string, "IPR:IPR000001;IPR:IPR000002"); /// ``` diff --git a/fa-compression/src/algorithm2/encode.rs b/fa-compression/src/algorithm2/encode.rs index ce599fc..d52844e 100644 --- a/fa-compression/src/algorithm2/encode.rs +++ b/fa-compression/src/algorithm2/encode.rs @@ -10,9 +10,9 @@ use super::CompressionTable; /// * `compression_table` - The compression table used for encoding. /// /// # Returns -/// +/// /// A compressed byte vector representing the encoded annotations. -/// +/// /// # Examples /// /// ``` @@ -22,7 +22,7 @@ use super::CompressionTable; /// let mut compression_table = CompressionTable::new(); /// compression_table.add_entry("IPR:IPR000001".to_string()); /// compression_table.add_entry("IPR:IPR000002".to_string()); -/// +/// /// let encoded = encode("IPR:IPR000001;IPR:IPR000002", compression_table); /// assert_eq!(encoded, vec![0, 0, 0, 1, 0, 0]); /// ``` diff --git a/fa-compression/src/algorithm2/mod.rs b/fa-compression/src/algorithm2/mod.rs index b04fd93..be08fe4 100644 --- a/fa-compression/src/algorithm2/mod.rs +++ b/fa-compression/src/algorithm2/mod.rs @@ -12,57 +12,61 @@ 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 { /// Creates a new compression table. - /// + /// /// # Returns - /// + /// /// An empty compression table. - /// + /// /// # Examples - /// + /// /// ``` /// use fa_compression::algorithm2::CompressionTable; - /// + /// /// let table = CompressionTable::new(); /// ``` pub fn new() -> CompressionTable { CompressionTable { - entries: Vec::new(), + entries: Vec::new() } } /// Adds a new entry to the compression table. - /// + /// /// # Arguments - /// + /// /// * `annotation` - The annotation to add to the compression table. - /// + /// /// # Examples - /// + /// /// ``` /// use fa_compression::algorithm2::CompressionTable; - /// + /// /// let mut table = CompressionTable::new(); /// table.add_entry("IPR:IPR000001".to_string()); /// table.add_entry("IPR:IPR000002".to_string()); /// ``` pub fn add_entry(&mut self, annotation: String) { - self.entries.push(CompressionTableEntry { annotation }); + self.entries.push(CompressionTableEntry { + annotation + }); } /// Returns the index of the given annotation in the compression table, if it exists. fn index_of(&self, annotation: &str) -> Option { - self.entries.iter().position(|entry| entry.annotation == annotation) + self.entries + .iter() + .position(|entry| entry.annotation == annotation) } }