mirror of
https://github.com/GuillemCastro/spotify-dl.git
synced 2025-05-10 06:15:32 +02:00
check if path exists (without extension)
This commit is contained in:
parent
961d975540
commit
1f333d6475
2 changed files with 23 additions and 18 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue