From 7f763ff500532aa24f7e47571567543e1fbc92a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Thu, 2 Feb 2023 21:55:16 -0300 Subject: [PATCH] move module `tests` to end of file --- src/extension.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/extension.rs b/src/extension.rs index 46b27dd..7e57b8d 100644 --- a/src/extension.rs +++ b/src/extension.rs @@ -170,6 +170,21 @@ pub fn extensions_from_path(path: &Path) -> Vec { extensions } +// Panics if formats has an empty list of compression formats +pub fn split_first_compression_format(formats: &[Extension]) -> (CompressionFormat, Vec) { + let mut extensions: Vec = flatten_compression_formats(formats); + let first_extension = extensions.remove(0); + (first_extension, extensions) +} + +pub fn flatten_compression_formats(extensions: &[Extension]) -> Vec { + extensions + .iter() + .flat_map(|extension| extension.compression_formats.iter()) + .copied() + .collect() +} + #[cfg(test)] mod tests { use super::*; @@ -185,18 +200,3 @@ mod tests { assert_eq!(formats, vec![Tar, Gzip]); } } - -// Panics if formats has an empty list of compression formats -pub fn split_first_compression_format(formats: &[Extension]) -> (CompressionFormat, Vec) { - let mut extensions: Vec = flatten_compression_formats(formats); - let first_extension = extensions.remove(0); - (first_extension, extensions) -} - -pub fn flatten_compression_formats(extensions: &[Extension]) -> Vec { - extensions - .iter() - .flat_map(|extension| extension.compression_formats.iter()) - .copied() - .collect() -} -- 2.11.4.GIT