#[derive(Display)]
{
// Attributes available to this derive:
#[scsys]
}
Expand description
the Display macro automatically implements the Display trait
for a struct or enum, using the scsys attributes to customize the output.
§Examples
§Example #1: Using the json attribute
use scsys_derive::Display;
#[derive(Display, serde::Deserialize, serde::Serialize)]
#[scsys(json)]
pub struct MyStruct {
pub name: String,
pub age: u32,
}
fn main() {
let my_struct = MyStruct {
name: "Alice".to_string(),
age: 30,
};
// This will print the struct in JSON format
println!("{}", my_struct);
}§Output:
{"name": "Alice", "age": 30}note: for now, the primary use case is to automatically implement the Display trait
for implementors of both Deserialize and Serialize from serde,