Avoid match for error handling where it makes sense

This commit is contained in:
Simon Bruder 2020-07-04 20:53:21 +02:00
parent 446ddb10e5
commit 0ea4a20326
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
2 changed files with 5 additions and 12 deletions

View file

@ -284,10 +284,7 @@ impl ssq::Step {
} }
} }
ssq::Step::Shock { beats } => { ssq::Step::Shock { beats } => {
let columns = match shock_step_generator.next() { let columns = shock_step_generator.next().unwrap_or_else(Vec::new);
Some(columns) => columns,
None => vec![],
};
for column in columns { for column in columns {
hit_objects.push(beatmap::HitObject::HitCircle { hit_objects.push(beatmap::HitObject::HitCircle {

View file

@ -166,13 +166,6 @@ struct BatchDDR2osu {
convert: converter::ddr2osu::Config, convert: converter::ddr2osu::Config,
} }
fn get_basename(path: &PathBuf) -> Option<&str> {
match path.file_stem() {
Some(stem) => stem.to_str(),
None => None,
}
}
fn read_musicdb(path: &PathBuf) -> Result<musicdb::MusicDB> { fn read_musicdb(path: &PathBuf) -> Result<musicdb::MusicDB> {
let extension = path.extension().and_then(|ext| ext.to_str()).unwrap_or(""); let extension = path.extension().and_then(|ext| ext.to_str()).unwrap_or("");
@ -372,7 +365,10 @@ fn main() -> Result<()> {
} }
SubCommand::DDR2osu(opts) => { SubCommand::DDR2osu(opts) => {
let basename = opts.basename.clone().unwrap_or( let basename = opts.basename.clone().unwrap_or(
get_basename(&opts.ssq_file) opts.ssq_file
.file_stem()
.map(|stem| stem.to_str())
.flatten()
.map(|basename| basename.to_string()) .map(|basename| basename.to_string())
.ok_or_else(|| { .ok_or_else(|| {
anyhow!( anyhow!(