1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4pub mod prelude;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9pub enum CheckResult {
10 Pass,
11 Fail,
12}
13
14impl CheckResult {
15 #[must_use]
16 pub const fn from_bool(condition: bool) -> Self {
17 if condition { Self::Pass } else { Self::Fail }
18 }
19
20 #[must_use]
21 pub const fn is_pass(self) -> bool {
22 matches!(self, Self::Pass)
23 }
24
25 #[must_use]
26 pub const fn is_fail(self) -> bool {
27 matches!(self, Self::Fail)
28 }
29}
30
31#[must_use]
32pub const fn check(condition: bool) -> CheckResult {
33 CheckResult::from_bool(condition)
34}
35
36#[must_use]
37pub const fn pass() -> CheckResult {
38 CheckResult::Pass
39}
40
41#[must_use]
42pub const fn fail() -> CheckResult {
43 CheckResult::Fail
44}
45
46#[cfg(test)]
47mod tests {
48 use super::{check, fail, pass};
49
50 #[test]
51 fn constructors_match_boolean_intent() {
52 assert!(check(true).is_pass());
53 assert!(pass().is_pass());
54 assert!(fail().is_fail());
55 }
56}