aboutsummaryrefslogtreecommitdiff
path: root/examples/example-pathfinder/src/sub
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-pathfinder/src/sub
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-pathfinder/src/sub')
-rw-r--r--examples/example-pathfinder/src/sub/mod.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/example-pathfinder/src/sub/mod.rs b/examples/example-pathfinder/src/sub/mod.rs
index ef10a75..6d15930 100644
--- a/examples/example-pathfinder/src/sub/mod.rs
+++ b/examples/example-pathfinder/src/sub/mod.rs
@@ -1,5 +1,6 @@
-use mingling::prelude::*;
use crate::Next;
+use mingling::prelude::*;
+use std::io::Write;
dispatcher!("greet", CMDGreet => EntryGreet);
pack!(ResultName = String);
@@ -15,7 +16,11 @@ pub fn handle_greet(args: EntryGreet) -> Next {
name
}
+/// Renders the name.
#[renderer]
-pub fn render_name(name: ResultName) {
- r_println!("Hello, {}!", *name);
+// But renderers cannot use the `async` keyword
+pub fn render_name(name: ResultName) -> RenderResult {
+ let mut render_result = RenderResult::new();
+ writeln!(render_result, "Hello, {}!", *name).ok();
+ render_result
}