error-fatality 0.1.2

Fatality extension to `thiserror::Error`
Documentation
use assert_matches::assert_matches;
use error_fatality::{Fatality, Nested, Split};
use thiserror::Error;

#[derive(Debug, Error, Fatality, Split)]
enum Yikes {
    #[fatal(true)]
    #[error("An apple a day")]
    Orange,

    #[fatal(true)]
    #[error("So dead")]
    Dead,
}

fn so_dead() -> Result<[u8; 32], Yikes> {
    Err(Yikes::Dead)
}

fn i_call_foo() -> Result<(), FatalYikes> {
    // availble via a convenience `trait Nested` that is implemented
    // for any `Result` whose error type implements `Split`.
    let _x: Result<[u8; 32], JfyiYikes> = so_dead().into_nested()?;
    unreachable!()
}

#[allow(clippy::print_stderr)]
fn i_call_foo_too() -> Result<(), FatalYikes> {
    if let Err(should_be_fatal) = so_dead() {
        // bail if bad, otherwise just log it
        eprintln!("You won't get here: {:?}", should_be_fatal.split()?);
    } else {
        unreachable!("`fn foo()` returns an error. qed");
    }
    unreachable!("Variant `Dead` is a `fatal` error. qed");
}

#[test]
fn test_i_call_foo_errors() {
    assert_matches!(i_call_foo(), Err(_e));
}

#[test]
fn test_i_call_foo_too_errors() {
    assert_matches!(i_call_foo_too(), Err(_e));
}