serde-json enum
This commit is contained in:
parent
8ddf0893ed
commit
32f9bc2ab7
|
@ -24,6 +24,7 @@ enum Color {
|
||||||
Green,
|
Green,
|
||||||
Yellow,
|
Yellow,
|
||||||
Red,
|
Red,
|
||||||
|
Custom(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
use serde_repr::{Deserialize_repr, Serialize_repr};
|
use serde_repr::{Deserialize_repr, Serialize_repr};
|
||||||
|
@ -63,6 +64,9 @@ fn main() -> anyhow::Result<()> {
|
||||||
let color_str = serde_json::to_string(&color)?;
|
let color_str = serde_json::to_string(&color)?;
|
||||||
dbg!(&color_str);
|
dbg!(&color_str);
|
||||||
|
|
||||||
|
let custom_color = Color::Custom("Morange".to_string());
|
||||||
|
dbg!(serde_json::to_string(&custom_color).unwrap());
|
||||||
|
|
||||||
let cl = CLike::Omaba;
|
let cl = CLike::Omaba;
|
||||||
let clrepr = serde_json::to_string(&cl)?;
|
let clrepr = serde_json::to_string(&cl)?;
|
||||||
dbg!(&clrepr);
|
dbg!(&clrepr);
|
||||||
|
|
Loading…
Reference in New Issue