diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-20 08:13:49 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-20 08:13:49 +0800 |
| commit | 9dc737acec1eab40ef65bef8e6c729a4e5e06401 (patch) | |
| tree | 05484fd697e7d2a047d8f525d6ede55c88010934 /CHANGELOG.md | |
| parent | a6697111573952903b3d9d0659ffe1af23432c3c (diff) | |
feat(macros): preserve user function as standalone item in codegen
Refactor #[chain], #[renderer], #[help], and #[completion] macros to
keep
the original user function as a named item instead of inlining its body.
Trait method implementations now call the original function by name,
injecting resources from the application context.
This improves debugging (stack traces reference user function names),
error messages, and macro expansion clarity.
Diffstat (limited to 'CHANGELOG.md')
| -rw-r--r-- | CHANGELOG.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 766090a..b2fea6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,16 @@ None _No migration is required for downstream code — all macros are re-exported with the same names and signatures as before._ +3. **[`macros`]** Refactored the code generation strategy for `#[chain]`, `#[renderer]`, `#[help]`, and `#[completion]` attribute macros. Instead of inlining the user's function body directly into the generated trait implementation, these macros now **preserve the original user function as a standalone item** and generate trait method implementations that **call the original function by name**, injecting resources from the application context. + + This approach provides several benefits: + + - **Better debugging and error messages** — The user's function exists as a named, callable item. Stack traces, profiler output, and error messages reference the user's function name (e.g., `handle_greet`) rather than an anonymous closure or inlined block, making debugging more intuitive. + + - **Clearer macro expansion** — The generated code maintains a clear separation between the original user function and the trait glue code, reducing the cognitive load when inspecting macro-expanded output. + + _No migration is required for downstream code — the behavior of all four macros is unchanged. This is purely an internal code generation refactoring._ + #### Features: 1. **[`core`]** Added `RenderResult::new()` method for creating a new `RenderResult` with default values (empty text and exit code 0). This provides a more explicit and discoverable constructor compared to `RenderResult::default()`, making it clearer when a fresh result is being created for use with `write!`/`writeln!`. |
