aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mingling_core/src/program.rs20
-rw-r--r--mingling_macros/src/dispatch_tree_gen.rs10
2 files changed, 24 insertions, 6 deletions
diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs
index a28e9b7..febb5db 100644
--- a/mingling_core/src/program.rs
+++ b/mingling_core/src/program.rs
@@ -426,8 +426,17 @@ pub fn get_nodes<C: ProgramCollect<Enum = C>>(
#[cfg(feature = "dispatch_tree")]
let r = C::get_nodes();
+ #[cfg(feature = "dispatch_tree")]
+ {
+ #[cfg(feature = "debug")]
+ {
+ let node_strs: Vec<String> = r.iter().map(|v| v.0.clone()).collect();
+ crate::info!("All Nodes: [{}]", node_strs.join(", "));
+ }
+ }
+
#[cfg(not(feature = "dispatch_tree"))]
- let r = program
+ let r: Vec<_> = program
.dispatcher
.iter()
.map(|disp| {
@@ -441,5 +450,14 @@ pub fn get_nodes<C: ProgramCollect<Enum = C>>(
})
.collect();
+ #[cfg(not(feature = "dispatch_tree"))]
+ {
+ #[cfg(feature = "debug")]
+ {
+ let node_strs: Vec<String> = r.iter().map(|v| v.0.clone()).collect();
+ crate::info!("All Nodes: [{}]", node_strs.join(", "));
+ }
+ }
+
return r;
}
diff --git a/mingling_macros/src/dispatch_tree_gen.rs b/mingling_macros/src/dispatch_tree_gen.rs
index 840fe15..3967aac 100644
--- a/mingling_macros/src/dispatch_tree_gen.rs
+++ b/mingling_macros/src/dispatch_tree_gen.rs
@@ -104,14 +104,14 @@ fn build_dispatch_body(nodes: &[(String, String)], depth: usize) -> TokenStream
let name_space = format!("{} ", name);
let name_lit = syn::LitStr::new(&name_space, proc_macro2::Span::call_site());
let disp_ident = syn::Ident::new(disp_type, proc_macro2::Span::call_site());
+ let prefix_word_count = name.split_whitespace().count();
quote! {
- if let Some(stripped) = raw_str.strip_prefix(#name_lit) {
+ if raw_str.starts_with(#name_lit) {
+ let prefix_len = #prefix_word_count;
+ let trimmed_args: Vec<String> = raw.iter().skip(prefix_len).cloned().collect();
let __cp = <#disp_ident as ::mingling::Dispatcher<Self::Enum>>::begin(
&#disp_ident::default(),
- stripped
- .split_whitespace()
- .map(String::from)
- .collect::<Vec<String>>(),
+ trimmed_args,
);
return match __cp {
::mingling::ChainProcess::Ok(any_output) => Ok(any_output.0),