diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-18 01:59:19 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-18 01:59:19 +0800 |
| commit | 6f2053e27a4dda5d6208b27bd652a9e861173e59 (patch) | |
| tree | 9d5862f942dd2bbb751bfcc11f49614f11c21705 /CHANGELOG.md | |
| parent | f5a4cebde2f12eb980de73ea41eb8d9e133ae49a (diff) | |
feat(macros): relax `#[help]` return type to accept `Into<RenderResult>`
Diffstat (limited to 'CHANGELOG.md')
| -rw-r--r-- | CHANGELOG.md | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fb0cc85..e85058c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -141,6 +141,26 @@ None } ``` +6. **[`macros:help`]** Removed the restriction that `#[help]` functions must return `::mingling::RenderResult`. The `#[help]` macro now accepts any return type (including no return type), and automatically converts the return value to `RenderResult` via `Into::into`. + + - Functions returning `RenderResult` work as before. + - Functions returning other types (e.g., `String`, `i32`, `()`) are converted via `Into<RenderResult>`. + - Functions with no return type (`-> ()` or omitted) return `()` which is converted to an empty `RenderResult` via `From<()>`. + + This makes `#[help]` consistent with the `#[renderer]` macro's ergonomic return type handling introduced in item 5 above. + + ```rust + #[help] + fn help_greeting(prev: EntryGreeting) -> String { + format!("Displaying help for greeting: {}", *prev) + } + + #[help] + fn help_void(prev: EntryVoid) { + // side effects only, returns empty RenderResult + } + ``` + #### **BREAKING CHANGES** (API CHANGES): 1. **[`macros:renderer`]** **[`macros:help`]** Removed `r_println!` and `r_print!` macros. The `#[renderer]` and `#[help]` macros no longer implicitly inject an internal `RenderResult` variable or provide `r_println!` / `r_print!` macros. |
