Documentation
#![allow(unused)]

use {
    derive_more::{Display, Error},
    problemo::*,
};

// Note that we need to implement PartialEq for has() to work
#[derive(Debug, Display, Error, PartialEq)]
pub enum OperatingSystemError {
    #[display("I/O")]
    IO,

    #[display("network")]
    Network,
}

fn read_the_file(path: &str) -> Result<String, Problem> {
    std::fs::read_to_string(path).via(OperatingSystemError::IO)
}

fn main() {
    if let Err(problem) = read_the_file("non-existing.txt") {
        /// Test for a specific variant with has_error()
        if problem.has_error(&OperatingSystemError::IO) {
            println!("Can't input or output!");
        }
        // Test for the whole enum with has_error_type()
        else if problem.has_error_type::<OperatingSystemError>() {
            println!("Your computer is broken!");
        }
    }
}