feat: return a vec instead of Option
This commit is contained in:
parent
4287fa3f4a
commit
b984f0455a
|
@ -189,11 +189,7 @@ impl TypedModule {
|
||||||
Definition::Validator(v) => {
|
Definition::Validator(v) => {
|
||||||
let module_name = self.name.as_str();
|
let module_name = self.name.as_str();
|
||||||
|
|
||||||
if let Some((k, v)) = v.into_function_definition(module_name, |f, _| Some(f)) {
|
for (k, v) in v.into_function_definitions(module_name) {
|
||||||
functions.insert(k, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some((k, v)) = v.into_function_definition(module_name, |_, f| f) {
|
|
||||||
functions.insert(k, v);
|
functions.insert(k, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,36 +557,32 @@ impl TypedValidator {
|
||||||
.or_else(|| self.fallback.find_node(byte_index))
|
.or_else(|| self.fallback.find_node(byte_index))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_function_definition<'a, F>(
|
pub fn into_function_definitions<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
module_name: &str,
|
module_name: &str,
|
||||||
select: F,
|
) -> Vec<(FunctionAccessKey, TypedFunction)> {
|
||||||
) -> Option<(FunctionAccessKey, TypedFunction)>
|
self.handlers
|
||||||
where
|
.iter()
|
||||||
F: Fn(&'a TypedFunction, Option<&'a TypedFunction>) -> Option<&'a TypedFunction> + 'a,
|
.chain(std::iter::once(&self.fallback))
|
||||||
{
|
.map(|handler| {
|
||||||
// match select(&self.fun, self.other_fun.as_ref()) {
|
let mut handler = handler.clone();
|
||||||
// None => None,
|
|
||||||
// Some(fun) => {
|
|
||||||
// let mut fun = fun.clone();
|
|
||||||
|
|
||||||
// fun.arguments = self
|
handler.arguments = self
|
||||||
// .params
|
.params
|
||||||
// .clone()
|
.clone()
|
||||||
// .into_iter()
|
.into_iter()
|
||||||
// .chain(fun.arguments)
|
.chain(handler.arguments)
|
||||||
// .collect();
|
.collect();
|
||||||
|
|
||||||
// Some((
|
(
|
||||||
// FunctionAccessKey {
|
FunctionAccessKey {
|
||||||
// module_name: module_name.to_string(),
|
module_name: module_name.to_string(),
|
||||||
// function_name: fun.name.clone(),
|
function_name: handler.name.clone(),
|
||||||
// },
|
},
|
||||||
// fun,
|
handler,
|
||||||
// ))
|
)
|
||||||
// }
|
})
|
||||||
// }
|
.collect()
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue