Crates.io | serialize_display_adapter_macro_derive |
lib.rs | serialize_display_adapter_macro_derive |
version | 0.1.3 |
source | src |
created_at | 2024-05-20 14:11:27.278271 |
updated_at | 2024-07-14 03:10:30.927819 |
description | Automatically impl Display for struct that implementated serde::Serialize |
homepage | https://github.com/Cryolitia/GPD-LinuxControls/tree/main/serialize_display_adapter_macro_derive |
repository | |
max_upload_size | |
id | 1245762 |
size | 3,505 |
use serde::Serialize;
use serialize_display_adapter_macro_derive::PrettyJsonSerializeDisplayAdapter;
#[derive(Serialize, PrettyJsonSerializeDisplayAdapter)]
struct Demo<'a> {
name: &'a str,
age: u8,
}
fn main() {
let name = "root";
let demo = Demo {
name: name.as_ref(),
age: 42,
};
print!("{}", demo)
}
// Should print:
//
// {
// "name": "root",
// "age": 42
// }