summaryrefslogtreecommitdiffstats
path: root/third_party/rust/failure_derive/tests/no_derive_display.rs
blob: 20eeb308c2dace3f9d1ccbc2aff0774efd831290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
extern crate failure;
#[macro_use]
extern crate failure_derive;

use failure::Fail;
use std::fmt::{self, Display};

#[derive(Debug, Fail)]
struct Foo;

impl Display for Foo {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("An error occurred.")
    }
}

#[test]
fn handwritten_display() {
    assert!(Foo.cause().is_none());
    assert_eq!(&format!("{}", Foo)[..], "An error occurred.");
}