Skip to content

Commit

Permalink
Implement Display for Function
Browse files Browse the repository at this point in the history
  • Loading branch information
SalsaGal committed Oct 7, 2024
1 parent b733594 commit 0c89581
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions sf2panlaw/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
fmt::Display,
fs::File,
io::Write,
path::{Path, PathBuf},
Expand All @@ -21,6 +22,15 @@ impl Function {
}
}

impl Display for Function {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Amplify => f.write_str("amplify"),
Self::Attenuate => f.write_str("attenuate"),
}
}
}

#[derive(Parser)]
#[clap(version)]
struct Args {
Expand Down Expand Up @@ -96,13 +106,8 @@ fn convert(path: &Path, function: Function) {
}

let mut output = File::create(format!(
"{}_{}.{}",
"{}_{function}.{}",
path.with_extension("").to_string_lossy(),
if function == Function::Amplify {
"amplified"
} else {
"attenuated"
},
path.extension().unwrap().to_string_lossy(),
))
.unwrap();
Expand Down

0 comments on commit 0c89581

Please sign in to comment.