refactor: convert _or_bail macros to ok_or functions

This commit is contained in:
ThetaDev 2022-10-18 19:09:16 +02:00
parent 9aafb84e0f
commit b5f6b7a174
13 changed files with 274 additions and 282 deletions

View file

@ -1,5 +1,4 @@
/// Returns an unwrapped Option if Some() otherwise returns the passed expression
#[allow(unused_macros)]
macro_rules! some_or_bail {
($opt:expr, $ret:expr $(,)?) => {{
match $opt {
@ -11,21 +10,7 @@ macro_rules! some_or_bail {
}};
}
/// Returns an unwrapped Option if Some() otherwise continues a loop.
#[allow(unused_macros)]
macro_rules! some_or_continue {
($opt:expr $(,)?) => {{
match $opt {
Some(stuff) => stuff,
None => {
continue;
}
}
}};
}
/// Returns an unwrapped Result if Ok() otherwise returns the passed expression
#[allow(unused_macros)]
macro_rules! ok_or_bail {
($result:expr, $ret:expr $(,)?) => {{
match $result {
@ -36,15 +21,3 @@ macro_rules! ok_or_bail {
}
}};
}
#[allow(unused_macros)]
macro_rules! ok_or_continue {
($opt:expr $(,)?) => {{
match $opt {
Ok(stuff) => stuff,
Err(_) => {
continue;
}
}
}};
}