summaryrefslogtreecommitdiffstats
path: root/vendor/derivative/tests/derive-debug-transparent.rs
blob: fcbc587f80fe0e4a58451e9aa07bd6421d05079d (plain)
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
#[cfg(feature = "use_core")]
extern crate core;

#[macro_use]
extern crate derivative;

#[derive(Derivative)]
#[derivative(Debug="transparent")]
struct A(isize);

#[derive(Derivative)]
#[derivative(Debug="transparent")]
struct B([isize; 1]);

#[derive(Derivative)]
#[derivative(Debug)]
enum C {
    Foo(u8),
    #[derivative(Debug="transparent")]
    Bar(u8),
}

trait ToDebug {
    fn to_show(&self) -> String;
}

impl<T: std::fmt::Debug> ToDebug for T {
    fn to_show(&self) -> String {
        format!("{:?}", self)
    }
}

#[test]
fn main() {
    assert_eq!(A(42).to_show(), "42".to_string());
    assert_eq!(B([42]).to_show(), "[42]".to_string());
    assert_eq!(C::Foo(42).to_show(), "Foo(42)".to_string());
    assert_eq!(C::Bar(42).to_show(), "42".to_string());
}