1
2#[macro_export]
3macro_rules! if_let_some {
4 ($var:pat = $value:expr) => {
5 let $var = if let Some(it) = $value {
6 it
7 } else {
8 return;
9 };
10 };
11
12 ($var:pat = $value:expr, $else_value:expr) => {
13 #[allow(clippy::if_let_some_result)]
14 let $var = if let Some(it) = $value {
15 it
16 } else {
17 return $else_value;
18 };
19 }
20}
21
22#[macro_export]
23macro_rules! if_let_ok {
24 ($var:pat = $value:expr, $else_value:expr) => {
25 let $var = match $value {
26 Ok(it) => it,
27 Err(err) => return $else_value(err),
28 };
29 }
30}
31