aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/example-exit-code/src/main.rs10
-rw-r--r--mingling/src/example_docs.rs10
-rw-r--r--mingling_macros/src/renderer.rs8
-rw-r--r--mingling_macros/src/res_injection.rs2
4 files changed, 10 insertions, 20 deletions
diff --git a/examples/example-exit-code/src/main.rs b/examples/example-exit-code/src/main.rs
index 39428e9..c9b3c92 100644
--- a/examples/example-exit-code/src/main.rs
+++ b/examples/example-exit-code/src/main.rs
@@ -12,10 +12,7 @@
//! ```
use mingling::prelude::*;
-use mingling::{
- res::{ExitCode, exit_code},
- setup::ExitCodeSetup,
-};
+use mingling::{res::ExitCode, setup::ExitCodeSetup};
fn main() {
let mut program = ThisProgram::new();
@@ -34,9 +31,8 @@ fn handle_error_entry(_prev: ErrorEntry, ec: &mut ExitCode) -> Next {
}
#[renderer]
-fn render_error(_prev: ResultError) {
- let exit_code = exit_code::<ThisProgram>();
- r_println!("Exit with exit code: {}", exit_code);
+fn render_error(_prev: ResultError, ec: &ExitCode) {
+ r_println!("Exit with exit code: {}", ec.exit_code);
}
gen_program!();
diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs
index 598e345..bb65280 100644
--- a/mingling/src/example_docs.rs
+++ b/mingling/src/example_docs.rs
@@ -368,10 +368,7 @@ pub mod example_dispatch_tree {}
/// main.rs
/// ```ignore
/// use mingling::prelude::*;
-/// use mingling::{
-/// res::{ExitCode, exit_code},
-/// setup::ExitCodeSetup,
-/// };
+/// use mingling::{res::ExitCode, setup::ExitCodeSetup};
///
/// fn main() {
/// let mut program = ThisProgram::new();
@@ -390,9 +387,8 @@ pub mod example_dispatch_tree {}
/// }
///
/// #[renderer]
-/// fn render_error(_prev: ResultError) {
-/// let exit_code = exit_code::<ThisProgram>();
-/// r_println!("Exit with exit code: {}", exit_code);
+/// fn render_error(_prev: ResultError, ec: &ExitCode) {
+/// r_println!("Exit with exit code: {}", ec.exit_code);
/// }
///
/// gen_program!();
diff --git a/mingling_macros/src/renderer.rs b/mingling_macros/src/renderer.rs
index db04c19..7f85a60 100644
--- a/mingling_macros/src/renderer.rs
+++ b/mingling_macros/src/renderer.rs
@@ -115,16 +115,14 @@ pub fn renderer_attr(attr: TokenStream, item: TokenStream) -> TokenStream {
quote! { #(#fn_body_stmts)* }
};
- // Build the original function with resource injection (no `.into()` — signature is exactly as user wrote)
+ // Build the original function with resource injection - use the resource bindings directly
+ // from the function parameters rather than re-fetching from context.
let original_fn_body = if has_resources {
- let wrapped_body =
- wrap_body_with_mut_resources(&fn_body_stmts, &mut_resources, program_type);
quote! {
let mut dummy_r = ::mingling::RenderResult::default();
{
let __renderer_inner_result = &mut dummy_r;
- #(#immut_resource_stmts)*
- #wrapped_body
+ #(#fn_body_stmts)*
}
#result_return
}
diff --git a/mingling_macros/src/res_injection.rs b/mingling_macros/src/res_injection.rs
index 0f180db..bdb3b73 100644
--- a/mingling_macros/src/res_injection.rs
+++ b/mingling_macros/src/res_injection.rs
@@ -149,7 +149,7 @@ pub(crate) fn generate_immut_resource_bindings<'a>(
.filter(|r| !r.is_mut)
.map(|res| {
let var_binding_name = syn::Ident::new(
- &format!("{}_binding", &res.var_name.to_string()),
+ &format!("__{}_binding", &res.var_name.to_string()),
res.var_name.span(),
);
let var_name = &res.var_name;