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); }