match match lole

I disliked how if Some else None repeated twice looked, but I'm not sure if this is better
This commit is contained in:
Quaternions 2023-09-30 02:53:25 -07:00
parent b3f7802046
commit d7010956b3

View File

@ -775,22 +775,24 @@ impl framework::Example for GraphicsData {
if let (Ok(()),Ok(()))=(std::io::Read::read_exact(&mut input, &mut first_8),std::io::Seek::rewind(&mut input)){ if let (Ok(()),Ok(()))=(std::io::Read::read_exact(&mut input, &mut first_8),std::io::Seek::rewind(&mut input)){
// //
if let Some(Ok((indexed_model_instances,spawn_point)))={ if let Some(Ok((indexed_model_instances,spawn_point)))={
if &first_8==b"<roblox!"{ match &first_8[0..4]{
if let Ok(dom) = rbx_binary::from_reader(input){ b"<rob"=>{
Some(load_roblox::generate_indexed_models_roblox(dom)) match match &first_8[4..8]{
}else{ b"lox!"=>rbx_binary::from_reader(input).map_err(|e|format!("{:?}",e)),
b"lox "=>rbx_xml::from_reader(input,rbx_xml::DecodeOptions::default()).map_err(|e|format!("{:?}",e)),
other=>Err(format!("Unknown Roblox file type {:?}",other)),
}{
Ok(dom)=>Some(load_roblox::generate_indexed_models_roblox(dom)),
Err(e)=>{
println!("Error loading roblox file:{:?}",e);
None None
},
} }
}else if &first_8==b"<roblox "{ },
if let Ok(dom) = rbx_xml::from_reader(input,rbx_xml::DecodeOptions::default()){ //b"VBSP"=>load_valve::generate_indexed_models_valve(input),
Some(load_roblox::generate_indexed_models_roblox(dom)) //b"SNFM"=>sniffer::generate_indexed_models(input),
}else{ //b"SNFB"=>sniffer::load_bot(input),
None _=>None,
}
//}else if &first_8[0..4]==b"VBSP"{
// self.generate_indexed_models_valve(input)
}else{
None
} }
}{ }{
//if generate_indexed_models succeeds, clear the previous ones //if generate_indexed_models succeeds, clear the previous ones