2018-12-04 06:17:53 +00:00
|
|
|
#![warn(clippy::single_match_else)]
|
|
|
|
|
|
|
|
enum ExprNode {
|
|
|
|
ExprAddrOf,
|
|
|
|
Butterflies,
|
|
|
|
Unicorns,
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE: ExprNode = ExprNode::Unicorns;
|
|
|
|
|
|
|
|
fn unwrap_addr() -> Option<&'static ExprNode> {
|
|
|
|
match ExprNode::Butterflies {
|
|
|
|
ExprNode::ExprAddrOf => Some(&NODE),
|
2018-12-09 22:26:16 +00:00
|
|
|
_ => {
|
|
|
|
let x = 5;
|
|
|
|
None
|
|
|
|
},
|
2018-12-04 06:17:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-31 10:19:49 +00:00
|
|
|
macro_rules! unwrap_addr {
|
|
|
|
($expression:expr) => {
|
|
|
|
match $expression {
|
|
|
|
ExprNode::ExprAddrOf => Some(&NODE),
|
|
|
|
_ => {
|
|
|
|
let x = 5;
|
|
|
|
None
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
unwrap_addr!(ExprNode::Unicorns);
|
|
|
|
}
|