check if path exists (without extension)

This commit is contained in:
Daniel 2023-02-01 20:34:23 +01:00
parent 961d975540
commit 1f333d6475
2 changed files with 23 additions and 18 deletions

View file

@ -22,16 +22,13 @@ impl FileSink {
}
impl Open for FileSink {
// use the unwrap_or_else method instead of the if let statement to handle the absence of a path value
fn open(path: Option<String>, _audio_format: AudioFormat) -> Self {
if let Some(path) = path {
let file = path;
FileSink {
sink: file,
content: Vec::new(),
metadata: None
}
} else {
panic!();
let file = path.unwrap_or_else(|| panic!());
FileSink {
sink: file,
content: Vec::new(),
metadata: None
}
}
}