aboutsummaryrefslogtreecommitdiff
path: root/examples/example-resources/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-resources/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-resources/src/main.rs')
-rw-r--r--examples/example-resources/src/main.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/examples/example-resources/src/main.rs b/examples/example-resources/src/main.rs
index 6c5bf84..b08ee26 100644
--- a/examples/example-resources/src/main.rs
+++ b/examples/example-resources/src/main.rs
@@ -14,9 +14,9 @@
//! Current directory: /home/alice/mingling/src
//! ```
-use std::path::PathBuf;
-
use mingling::prelude::*;
+use std::io::Write;
+use std::path::PathBuf;
// Create resource
// ______________ Resource needs to
@@ -58,8 +58,15 @@ fn render_modify_current(args: EntryModifyCurrent, current_dir: &mut ResCurrentD
// /
/// Renders the current directory path. |
#[renderer] // vvvvvvvvvvvvvv
-fn render_current(_: EntryCurrent, current_dir: &ResCurrentDir) {
- r_println!("Current directory: {}", current_dir.current_dir.display());
+fn render_current(_: EntryCurrent, current_dir: &ResCurrentDir) -> RenderResult {
+ let mut render_result = RenderResult::new();
+ write!(
+ render_result,
+ "Current directory: {}",
+ current_dir.current_dir.display()
+ )
+ .ok();
+ render_result
}
gen_program!();