diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-11 15:15:12 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-11 15:21:40 +0800 |
| commit | 95815041fe2817b4b6bdba6b4f332c90320af7bb (patch) | |
| tree | 224f3479eca9e44caa247132ecab42f8825b167c /examples/example-enum-tag | |
| parent | 356879cfd6149bdb235b4e02c0f351a4d2246202 (diff) | |
refactor(examples): migrate renderers to return RenderResult and add
std::io::Write import
Replace r_println!/r_print! macro usage across all example renderers
with
explicit RenderResult construction using std::io::Write, enabling more
flexible output handling and reducing reliance on macro-side effects.
Diffstat (limited to 'examples/example-enum-tag')
| -rw-r--r-- | examples/example-enum-tag/src/main.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/example-enum-tag/src/main.rs b/examples/example-enum-tag/src/main.rs index ad9db82..01c7767 100644 --- a/examples/example-enum-tag/src/main.rs +++ b/examples/example-enum-tag/src/main.rs @@ -19,6 +19,7 @@ use mingling::{ macros::suggest_enum, parser::PickableEnum, prelude::*, EnumTag, Groupped, ShellContext, Suggest, }; +use std::io::Write; // Define the enum and derive the EnumTag trait // ________ adds metadata to the enum, enabling it to: @@ -83,10 +84,11 @@ fn handle_language_selection(args: EntryLanguageSelection) -> Next { /// Renders the selected programming language with its name and description. #[renderer] -fn render_programming_language(lang: ProgrammingLanguages) { - // You can use `enum_info()` to get the name and description of the current enum +pub fn render_programming_language(lang: ProgrammingLanguages) -> RenderResult { + let mut render_result = RenderResult::new(); let (name, desc) = lang.enum_info(); - r_println!("Selected: {} ({})", name, desc) + writeln!(render_result, "Selected: {} ({})", name, desc).ok(); + render_result } #[completion(EntryLanguageSelection)] |
