Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I destructuring-match syntax::ptr::P?

Tags:

rust

I have a function which tries to match an syntax::ast::ExprBinary(syntax::ast::BinOp, syntax::ptr::P<ast::Expr>, syntax::ptr::P<syntax::ast::Expr>), but I cannot find the right syntax to match the P so I get the contained expression out of it. I see that I can use Deref to get at the Expr, but this is cumbersome.

Is there a way to get rid of the P within the match (or if let) clause?

like image 413
llogiq Avatar asked Sep 19 '26 02:09

llogiq


1 Answers

There's no way to pattern match through a P: the field is private and we don't have generalised pointer pattern matching (yet).

The only ways to get at the contained data are Deref (for a &), and the methods and_then and map (for by-value).

like image 156
huon Avatar answered Sep 22 '26 06:09

huon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!