aboutsummaryrefslogtreecommitdiff
path: root/examples/example-general-renderer
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-06-26 06:08:12 +0800
committer魏曹先生 <1992414357@qq.com>2026-06-26 06:08:12 +0800
commite735671acb3a81e1b7e334e56b9ef3963ba0c2fc (patch)
tree46562d6630bb1582b41b6741a7a4f482febf84da /examples/example-general-renderer
parent473cd8e575d03d8bd5439e81cb6835f56a1e964f (diff)
feat(core): decouple structured output from Groupped trait
Introduce `StructuralData` sealed trait and `pack_structural!` / `group_structural!` / `derive(StructuralData)` macros to control structured rendering separately from grouping. `Groupped` no longer requires `Serialize`.
Diffstat (limited to 'examples/example-general-renderer')
-rw-r--r--examples/example-general-renderer/src/main.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/example-general-renderer/src/main.rs b/examples/example-general-renderer/src/main.rs
index c923d28..1e02afb 100644
--- a/examples/example-general-renderer/src/main.rs
+++ b/examples/example-general-renderer/src/main.rs
@@ -18,7 +18,7 @@
//! ```
use mingling::prelude::*;
-use mingling::{parser::Picker, setup::GeneralRendererSetup, Groupped};
+use mingling::{parser::Picker, setup::GeneralRendererSetup, StructuralData, Groupped};
use serde::Serialize;
dispatcher!("render", CMDRender => EntryRender);
@@ -34,11 +34,12 @@ fn main() {
// --------- IMPORTANT ---------
// For beautiful output structure, do not use `pack!` to wrap the types that need to be output.
// Instead, manually implement
-// ____________________ Implement serde::Serialize
-// / _________ Implement mingling::Groupped
-// | / to ensure Mingling can recognize the type
-// vvvvvvvvv vvvvvvvv
-#[derive(Serialize, Groupped)]
+// __________________________________ Mark as structured data so it can be rendered
+// / ____________________ Implement serde::Serialize
+// | / _________ Implement mingling::Groupped
+// | | / to ensure Mingling can recognize the type
+// vvvvvvvvvvvv vvvvvvvvv vvvvvvvv
+#[derive(StructuralData, Serialize, Groupped)]
struct Info {
#[serde(rename = "member_name")]
name: String,