Avoid match for error handling where it makes sense
This commit is contained in:
parent
446ddb10e5
commit
0ea4a20326
|
@ -284,10 +284,7 @@ impl ssq::Step {
|
|||
}
|
||||
}
|
||||
ssq::Step::Shock { beats } => {
|
||||
let columns = match shock_step_generator.next() {
|
||||
Some(columns) => columns,
|
||||
None => vec![],
|
||||
};
|
||||
let columns = shock_step_generator.next().unwrap_or_else(Vec::new);
|
||||
|
||||
for column in columns {
|
||||
hit_objects.push(beatmap::HitObject::HitCircle {
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -166,13 +166,6 @@ struct BatchDDR2osu {
|
|||
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> {
|
||||
let extension = path.extension().and_then(|ext| ext.to_str()).unwrap_or("");
|
||||
|
||||
|
@ -372,7 +365,10 @@ fn main() -> Result<()> {
|
|||
}
|
||||
SubCommand::DDR2osu(opts) => {
|
||||
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())
|
||||
.ok_or_else(|| {
|
||||
anyhow!(
|
||||
|
|
Reference in a new issue