aboutsummaryrefslogtreecommitdiff
path: root/examples/example-structural-renderer/src/main.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-11 15:15:12 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-11 15:21:40 +0800
commit95815041fe2817b4b6bdba6b4f332c90320af7bb (patch)
tree224f3479eca9e44caa247132ecab42f8825b167c /examples/example-structural-renderer/src/main.rs
parent356879cfd6149bdb235b4e02c0f351a4d2246202 (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-structural-renderer/src/main.rs')
-rw-r--r--examples/example-structural-renderer/src/main.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/example-structural-renderer/src/main.rs b/examples/example-structural-renderer/src/main.rs
index 21077e7..13c4c84 100644
--- a/examples/example-structural-renderer/src/main.rs
+++ b/examples/example-structural-renderer/src/main.rs
@@ -18,8 +18,9 @@
//! ```
use mingling::prelude::*;
-use mingling::{parser::Picker, setup::StructuralRendererSetup, StructuralData, Groupped};
+use mingling::{Groupped, StructuralData, parser::Picker, setup::StructuralRendererSetup};
use serde::Serialize;
+use std::io::Write;
dispatcher!("render", CMDRender => EntryRender);
@@ -64,8 +65,10 @@ fn parse_render(prev: EntryRender) -> Next {
/// Implement default renderer for when structural_renderer is not specified
#[renderer]
-fn render_info(prev: Info) {
- r_println!("{} is {} years old", prev.name, prev.age);
+fn render_info(prev: Info) -> RenderResult {
+ let mut render_result = RenderResult::new();
+ writeln!(render_result, "{} is {} years old", prev.name, prev.age).ok();
+ render_result
}
gen_program!();