inspect-rs 0.1.0

Universal introspection for Rust
Documentation
use std::collections::HashMap;

use inspect_rs::{Inspect, InspectCx, format_tree};

#[derive(Inspect)]
struct Stats {
    counts: HashMap<String, u64>,
    recent: Vec<String>,
}

fn main() {
    let mut counts = HashMap::new();
    counts.insert("requests".to_string(), 1234);
    counts.insert("errors".to_string(), 5);
    counts.insert("warnings".to_string(), 23);

    let stats = Stats {
        counts,
        recent: vec!["Request A".to_string(), "Request B".to_string(), "Request C".to_string()],
    };

    let mut cx = InspectCx::new();
    let inspected = stats.inspect(&mut cx);

    println!("{}", format_tree(&inspected));
}