From 994eb9c4beadcfda80a54c612af73156103b5feb Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 24 Jan 2024 14:58:27 -0800 Subject: [PATCH] remove unnecessary Option --- src/main.rs | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/main.rs b/src/main.rs index f9674f3..5465ce0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1313,7 +1313,7 @@ async fn model_node(search_name:&str,mut file:tokio::fs::File)->AResult)->AResult>{ +async fn locate_override_file(entry:&tokio::fs::DirEntry,style:Option)->AResult{ let contents_folder=entry.path(); let file_name=entry.file_name(); let search_name=file_name.to_str().unwrap(); @@ -1333,7 +1333,7 @@ async fn locate_override_file(entry:&tokio::fs::DirEntry,style:Optionscript_node(search_name,file,hint).await?, (Err(QueryResolveError::NotFound),Ok(file))=>model_node(search_name,file).await?, (Ok(_),Ok(_))=>Err(QueryResolveError::Ambiguous)?, @@ -1345,7 +1345,7 @@ async fn locate_override_file(entry:&tokio::fs::DirEntry,style:OptionErr(e)? - })) + }) } @@ -1354,7 +1354,7 @@ enum FileDiscernment{ Script(ScriptHint), } -async fn discern_file(entry:&tokio::fs::DirEntry,style:Option)->AResult>{ +async fn discern_file(entry:&tokio::fs::DirEntry,style:Option)->AResult{ let path=entry.path(); let file_discernment=match path.extension(){ Some(extension)=>match extension.to_str(){ @@ -1375,10 +1375,10 @@ async fn discern_file(entry:&tokio::fs::DirEntry,style:Option)-> } let search_name=path.to_str().unwrap(); let file=tokio::fs::File::open(path.as_path()).await?; - Ok(Some(match file_discernment{ + Ok(match file_discernment{ FileDiscernment::Model=>model_node(search_name,file).await?, FileDiscernment::Script(hint)=>script_node(search_name,file,hint).await?, - })) + }) } @@ -1479,25 +1479,22 @@ async fn compile(config:CompileConfig)->AResult<()>{ let style=config.style; join_set.spawn(async move{ let met=entry.metadata().await?; - let scooby_doo=if met.is_dir(){ - locate_override_file(&entry,style).await + let compile_class=if met.is_dir(){ + locate_override_file(&entry,style).await? }else{ - discern_file(&entry,style).await + discern_file(&entry,style).await? }; //discern that bad boy - Ok::<_,anyhow::Error>(match scooby_doo?{ - Some(compile_class)=>{ - //prepare data structure - Some(match compile_class.class{ - CompileClass::Folder=>PreparedData::Builder(rbx_dom_weak::InstanceBuilder::new("Folder").with_name(compile_class.name.as_str())), - CompileClass::Script(source)=>PreparedData::Builder(script_builder("Script",compile_class.name.as_str(),source)), - CompileClass::LocalScript(source)=>PreparedData::Builder(script_builder("LocalScript",compile_class.name.as_str(),source)), - CompileClass::ModuleScript(source)=>PreparedData::Builder(script_builder("ModuleScript",compile_class.name.as_str(),source)), - CompileClass::Model(buf)=>PreparedData::Model(rbx_xml::from_reader_default(std::io::Cursor::new(buf))?), - }) - }, - None=>None, - }) + Ok::<_,anyhow::Error>( + //prepare data structure + match compile_class.class{ + CompileClass::Folder=>PreparedData::Builder(rbx_dom_weak::InstanceBuilder::new("Folder").with_name(compile_class.name.as_str())), + CompileClass::Script(source)=>PreparedData::Builder(script_builder("Script",compile_class.name.as_str(),source)), + CompileClass::LocalScript(source)=>PreparedData::Builder(script_builder("LocalScript",compile_class.name.as_str(),source)), + CompileClass::ModuleScript(source)=>PreparedData::Builder(script_builder("ModuleScript",compile_class.name.as_str(),source)), + CompileClass::Model(buf)=>PreparedData::Model(rbx_xml::from_reader_default(std::io::Cursor::new(buf))?), + } + ) }); } } @@ -1505,9 +1502,8 @@ async fn compile(config:CompileConfig)->AResult<()>{ //push child objects onto dom while let Some(goober)=join_set.join_next().await{ match goober??{ - Some(PreparedData::Model(mut model_dom))=>model_dom.transfer(model_dom.root().children()[0],&mut dom,item_ref), - Some(PreparedData::Builder(script))=>{dom.insert(item_ref,script);}, - None=>print!("There was a None"), + PreparedData::Model(mut model_dom)=>model_dom.transfer(model_dom.root().children()[0],&mut dom,item_ref), + PreparedData::Builder(script)=>{dom.insert(item_ref,script);}, } } //push dom children objects onto stack