From 32f9bc2ab701662d77ace9a15bb0f03948ec432f Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Mon, 24 Jun 2024 13:35:35 +0200 Subject: [PATCH] serde-json enum --- members/serde-json-demo/src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/members/serde-json-demo/src/main.rs b/members/serde-json-demo/src/main.rs index 825f7b0..be17d9d 100644 --- a/members/serde-json-demo/src/main.rs +++ b/members/serde-json-demo/src/main.rs @@ -24,6 +24,7 @@ enum Color { Green, Yellow, Red, + Custom(String) } use serde_repr::{Deserialize_repr, Serialize_repr}; @@ -63,6 +64,9 @@ fn main() -> anyhow::Result<()> { let color_str = serde_json::to_string(&color)?; dbg!(&color_str); + let custom_color = Color::Custom("Morange".to_string()); + dbg!(serde_json::to_string(&custom_color).unwrap()); + let cl = CLike::Omaba; let clrepr = serde_json::to_string(&cl)?; dbg!(&clrepr);