result-exos #1

Merged
lilymonade merged 4 commits from result-exos into main 2025-03-11 17:43:29 +00:00
Showing only changes of commit 4c9eef9b41 - Show all commits

View 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