result-exos #1
19
subject_source/src/errors/result.rs
Normal file
19
subject_source/src/errors/result.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
pub fn is_err(res: &Result<i32, &str>) -> bool {
|
||||||
|
match res {
|
||||||
|
Err(_) => true,
|
||||||
|
Ok(_) => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_ok(res: &Result<i32, &str>) -> bool {
|
||||||
|
!is_err(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_err_or_panic(res: Result<i32, &str>) -> &str {
|
||||||
|
match res {
|
||||||
|
Err(e) => e,
|
||||||
|
Ok(_) => panic!("result was not an error"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn
|
||||||
Loading…
x
Reference in New Issue
Block a user