There are a number of questions on this site about pattern matching Box<>
, and it currently can't be done on stable Rust (one, two, three etc.). But those questions are all about single levels of box. I have a deeply nested Box/Enum tree. Basically I want to do this:
match node {
ConstantExpression::ConstantPrimary(Box(ConstantPrimary::PrimaryLiteral(Box(
PrimaryLiteral::Number(Box(Number::IntegralNumber(Box(
IntegralNumber::DecimalNumber(Box(DecimalNumber::UnsignedNumber(unsigned_number))),
)))),
)))) => Some(unsigned_number),
_ => None,
};
Is there a way to do this on stable Rust that isn't extremely verbose?
(Edit: This is not a duplicate of this question; I already know you can't do it using match
. I was asking for an alternative way to do it.)