From 09dd44294850e2b2e9ad88490d6f7a712aca2168 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 6 Oct 2024 10:49:41 -0700 Subject: [PATCH] class tree walk can be idiomized with find_map and transpose --- src/runner/instance.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/runner/instance.rs b/src/runner/instance.rs index 80dedd5..ed94bac 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -256,15 +256,9 @@ impl mlua::UserData for Instance{ database:db, descriptor:Some(class), }; - Ok(loop{ - match iter.next(){ - Some(class)=>match cf.get_or_create_class_function(lua,&class.name,index_str)?{ - Some(function)=>break Some(function), - None=>(), - }, - None=>break None, - } - }) + iter.find_map(|class| + cf.get_or_create_class_function(lua,&class.name,index_str).transpose() + ).transpose() })?{ return function.into_lua(lua); }