use serde::Serialize;
use serde_yml::{to_string, Result};
#[derive(Serialize)]
struct Address {
street: String,
city: String,
country: String,
}
#[derive(Serialize)]
struct User {
name: String,
age: u32,
address: Address,
}
pub(crate) fn main() -> Result<()> {
println!("\n❯ Executing examples/serializer/structs.rs");
let user = User {
name: "Alice".to_string(),
age: 25,
address: Address {
street: "123 Main St".to_string(),
city: "Anytown".to_string(),
country: "USA".to_string(),
},
};
let yaml = to_string(&user)?;
println!("\n✅ User serialized to YAML:\n{}", yaml);
Ok(())
}