1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

use std::fmt::Debug;

pub fn putone<T: Debug>(a: T) {
    println!("{:?}", a);
}

#[macro_export]
macro_rules! puts {
    ( $( $a: expr ),* ) => {
        {
            $( print!("{:?} ", $a); )*
            println!("");
        }
    }
}

#[cfg(test)]
mod tests {

    // For these tests to make sense, 
    // run `cargo test -- --nocapture`
    //
    
    #[derive(Debug)]
    enum Color {
        Red,
        Blue,
    }
    
    #[derive(Debug)]
    struct Apple {
        width: i64,
        color: Color,
    }

    #[test]
    fn test_putone() {
        super::putone(2);
    }

    #[test]
    fn test_puts() {
        puts!(2, "hi", &[2,3,4]);
        puts!(Apple { width: 4, color: Color::Blue }, Color::Red)
    }
}