this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: remove unused KNOWN_EXTENSIONS, replace unreachable fallbacks with asserts

+14 -31
-3
src/backends/mod.rs
··· 32 32 _ => None, 33 33 } 34 34 } 35 - 36 - /// All known single-format extensions, used for filename detection. 37 - pub const KNOWN_EXTENSIONS: &[&str] = &["tar", "gz", "xz", "bz2", "zip", "zst", "lz4"];
+14 -28
src/backends/pipeline.rs
··· 150 150 151 151 impl Compressor for Pipeline { 152 152 fn name(&self) -> &str { 153 - if let Some(comp) = self.compressors.last() { 154 - comp.name() 155 - } else { 156 - "multi" 157 - } 153 + self.compressors 154 + .last() 155 + .expect("pipeline is never empty") 156 + .name() 158 157 } 159 158 160 159 fn extension(&self) -> &str { 161 - if let Some(comp) = self.compressors.last() { 162 - comp.extension() 163 - } else { 164 - "multi" 165 - } 160 + self.compressors 161 + .last() 162 + .expect("pipeline is never empty") 163 + .extension() 166 164 } 167 165 168 166 fn default_extracted_target(&self) -> ExtractedTarget { 169 - // After full extraction, the result is what the innermost compressor produces 170 - if let Some(comp) = self.compressors.first() { 171 - comp.default_extracted_target() 172 - } else { 173 - ExtractedTarget::FILE 174 - } 167 + self.compressors 168 + .first() 169 + .expect("pipeline is never empty") 170 + .default_extracted_target() 175 171 } 176 172 177 173 fn default_compressed_filename(&self, in_path: &Path) -> String { ··· 213 209 } 214 210 215 211 fn compress(&self, input: CmprssInput, output: CmprssOutput) -> Result<(), io::Error> { 216 - if self.compressors.is_empty() { 217 - return Err(io::Error::new( 218 - io::ErrorKind::Other, 219 - "No compressors in pipeline", 220 - )); 221 - } 212 + debug_assert!(!self.compressors.is_empty(), "pipeline is never empty"); 222 213 223 214 if self.compressors.len() == 1 { 224 215 return self.compressors[0].compress(input, output); ··· 268 259 } 269 260 270 261 fn extract(&self, input: CmprssInput, output: CmprssOutput) -> Result<(), io::Error> { 271 - if self.compressors.is_empty() { 272 - return Err(io::Error::new( 273 - io::ErrorKind::Other, 274 - "No compressors in pipeline for extraction", 275 - )); 276 - } 262 + debug_assert!(!self.compressors.is_empty(), "pipeline is never empty"); 277 263 278 264 if self.compressors.len() == 1 { 279 265 return self.compressors[0].extract(input, output);