to-display 0.1.2

A trait that is Display or can be converted to Display
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use to_display::DisplayConfig;
use to_display::ToDisplay;

#[test]
fn test_display_result() {
    let result: Result<i32, &str> = Ok(42);
    assert_eq!(result.display().to_string(), "Ok(42)");

    let result: Result<i32, &str> = Err("error");
    assert_eq!(result.display().to_string(), "Err(error)");

    let result: Result<Option<i32>, &str> = Ok(Some(42));
    assert_eq!(result.display().to_string(), "Ok(42)");

    let result: Result<Option<i32>, &str> = Ok(Some(42));
    assert_eq!(result.display().verbose().to_string(), "Ok(Some(42))");
}