aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-11 16:16:40 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-11 16:16:40 +0800
commit25e37e54220fce49a0387dc0a7c332b19e4240be (patch)
tree9dcabb3690206c626c424261b76d3b19e449b84b
parent85c8986f26031cc11ed1e1da77fdf099b5814381 (diff)
docs(changelog): document RenderResult::new and removed r_print macrosversion/0.3.0
-rw-r--r--CHANGELOG.md27
-rw-r--r--mingling/src/example_docs.rs4
2 files changed, 27 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b07be56..361338f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -62,11 +62,34 @@ None
#### Features:
-None
+1. **[`core`]** Added `RenderResult::new()` method for creating a new `RenderResult` with default values (empty text and exit code 0). This provides a more explicit and discoverable constructor compared to `RenderResult::default()`, making it clearer when a fresh result is being created for use with `write!`/`writeln!`.
+
+ ```rust
+ let mut result = RenderResult::new();
+ writeln!(result, "Hello!").ok();
+ result
+ ```
+
+ The method is equivalent to `RenderResult::default()` but serves as a more idiomatic entry point for renderer functions.
#### **BREAKING CHANGES** (API CHANGES):
-None
+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.
+
+ Renderers and help functions must now explicitly create and return a `RenderResult`:
+
+ ```rust
+ use mingling::prelude::*;
+
+ #[renderer]
+ fn render_greeting(greeting: ResultGreeting) -> RenderResult {
+ let mut result = RenderResult::new();
+ writeln!(result, "Hello, {}!", *greeting).ok();
+ result
+ }
+ ```
+
+ All examples, docs, and test cases across the repository have been updated to use the new pattern: creating a `RenderResult` with `RenderResult::new()` or `RenderResult::default()`, writing with `write!`/`writeln!` from `std::io::Write`, and returning the result.
---
diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs
index 4b34d0d..4699a50 100644
--- a/mingling/src/example_docs.rs
+++ b/mingling/src/example_docs.rs
@@ -765,7 +765,7 @@ pub mod example_completion {}
/// #[renderer]
/// pub fn render_address(addr: Address) -> RenderResult {
/// let mut render_result = RenderResult::new();
-/// write!(render_result, "Connected to \"{}\"", addr.to_string()).ok();
+/// write!(render_result, "Connected to \"{}\"", addr).ok();
/// render_result
/// }
///
@@ -1705,7 +1705,7 @@ pub mod example_lazy_resources {}
/// #[renderer] // vvvvvvv
/// fn render_error_io(err: ErrorIo) -> RenderResult {
/// let mut render_result = RenderResult::new();
-/// write!(render_result, "IO_ERROR: {}", err.to_string()).ok();
+/// write!(render_result, "IO_ERROR: {}", err).ok();
/// render_result
/// }
///