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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Module implementing custom helpers for working with results.
/// `on_result` lets you inline the underline actions you want a result to
/// be handled both for it's ok state and error state.
///
/// # Example
///
/// ```rust
/// use foundation_core::*;
///
///
/// let good_result: Result<i32, &str> = Ok(10);
/// on_result!(good_result, val => println!("Success: {}", val), err => println!("Error: {}", err));
///
/// let bad_result: Result<i32, &str> = Err("Error occurred");
/// on_result!(bad_result, val => println!("Success: {}", val), err => println!("Error: {}", err));
///
/// ```
/// `unwrap_or_panic_log` lets you unwrap the underlying OK value from a result, logging
/// and panicing on the error state.
///
/// # Example
///
/// ```rust
/// use foundation_core::*;
///
/// let result: Result<i32, String> = Ok(5);
/// let value = unwrap_or_panic_log!(result);
/// println!("Value: {}", value);
///
/// ```
/// `is_ok` lets you perform an equality on the Ok value returning
/// true or false if the values match or a definite false if its an Error
/// and not a Ok value.
///
/// # Example
///
/// ```rust
/// use foundation_core::*;
///
/// let result: Result<i32, String> = Ok(5);
/// assert!(is_ok!(result, 5));
///
///
/// ```