RUST: Print container contents

//! Comprehensive examples of printing Rust data containers

use std::collections::HashMap;
use std::fmt;

// 1. Struct with Debug and custom Display implementations
#[derive(Debug)]
struct Person {
    name: String,
    age: u8,
}

impl fmt::Display for Person {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{} ({} years old)", self.name, self.age)
    }
}

// 2. Custom container type
#[derive(Debug)]
struct Point {
    x: i32,
    y: i32,
}

pub fn demonstrate_printing() {
    // 1. Arrays
    let arr = [1, 2, 3];
    println!("\n--- Array Printing ---");
    println!("Debug: {:?}", arr);
    println!("Pretty: {:#?}", arr);

    // 2. Vectors
    let vec = vec!["apple", "banana", "cherry"];
    println!("\n--- Vector Printing ---");
    println!("Debug: {:?}", vec);
    println!("With indices:");
    for (i, item) in vec.iter().enumerate() {
        println!("  {}: {}", i, item);
    }

    // 3. Structs
    let person = Person { name: "Alice".to_string(), age: 30 };
    println!("\n--- Struct Printing ---");
    println!("Debug: {:?}", person);
    println!("Display: {}", person);

    // 4. Tuples
    let tuple = (42, "hello", 3.14);
    println!("\n--- Tuple Printing ---");
    println!("Debug: {:?}", tuple);

    // 5. HashMaps
    let mut map = HashMap::new();
    map.insert("key1", "value1");
    map.insert("key2", "value2");
    println!("\n--- HashMap Printing ---");
    println!("Debug: {:?}", map);
    println!("Pretty: {:#?}", map);

    // 6. Options
    let some = Some(42);
    let none: Option<i32> = None;
    println!("\n--- Option Printing ---");
    println!("Some: {:?}", some);
    println!("None: {:?}", none);

    // 7. Results
    let ok: Result<i32, &str> = Ok(42);
    let err: Result<i32, &str> = Err("failure");
    println!("\n--- Result Printing ---");
    println!("Ok: {:?}", ok);
    println!("Err: {:?}", err);

    // 8. Custom Point struct
    let point = Point { x: 10, y: 20 };
    println!("\n--- Custom Type Printing ---");
    println!("Debug: {:?}", point);
    println!("Pretty debug: {:#?}", point);
}

// Remember to add to src/menu_items/mod.rs:
// pub mod rust_prints;

"Aufwachen, arschloch!"