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
use core::ops::Deref;

pub const OK: Success = Success { ok: true };
pub const FAIL: Success = Success { ok: false };

#[must_use]
pub struct Success {
    pub ok: bool,
}

pub struct Failure {
    pub fail: bool,
}

impl Deref for Success {
    type Target = Failure;

    fn deref(&self) -> &Self::Target {
        if self.ok {
            &Failure { fail: false }
        } else {
            &Failure { fail: true }
        }
    }
}