How do I match against a nested String
in Rust? Suppose I have an enum like
pub enum TypeExpr {
Ident((String, Span)),
// other variants...
}
and a value lhs
of type &Box<TypeExpr>
. How do I check whether it is an Ident
with the value "float"?
I tried
if let TypeExpr::Ident(("float", lhs_span)) = **lhs {}
but this doesn't work since TypeExpr
contains a String
, not a &str
. I tried every variation of the pattern I could think of, but nothing seems to work.