use treelog::Tree;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("RON Serialization Example\n");
let tree = Tree::Node(
"root".to_string(),
vec![
Tree::Leaf(vec!["item1".to_string()]),
Tree::Node(
"sub".to_string(),
vec![
Tree::Leaf(vec!["subitem1".to_string()]),
Tree::Leaf(vec!["subitem2".to_string()]),
],
),
],
);
println!("Original tree:");
println!("{}", tree.render_to_string());
println!("\n---\n");
let ron = tree.to_ron()?;
println!("RON representation:");
println!("{}", ron);
println!("\n---\n");
let ron_pretty = tree.to_ron_pretty()?;
println!("Pretty RON representation:");
println!("{}", ron_pretty);
println!("\n---\n");
let deserialized = Tree::from_ron(&ron)?;
println!("Deserialized tree:");
println!("{}", deserialized.render_to_string());
assert_eq!(tree, deserialized);
println!("\n✓ Round-trip successful!");
Ok(())
}