简体   繁体   English

我如何解构匹配语法:: ptr :: P?

[英]How do I destructuring-match syntax::ptr::P?

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. 我有一个函数试图匹配syntax::ast::ExprBinary(syntax::ast::BinOp, syntax::ptr::P<ast::Expr>, syntax::ptr::P<syntax::ast::Expr>) ,但我找不到与P匹配的正确语法,所以我得到了包含的表达式。 I see that I can use Deref to get at the Expr , but this is cumbersome. 我看到我可以使用Deref来获得Expr ,但这很麻烦。

Is there a way to get rid of the P within the match (or if let ) clause? 有没有办法摆脱match (或if let )条款中的P

There's no way to pattern match through a P : the field is private and we don't have generalised pointer pattern matching (yet). 没有办法通过P模式匹配: 该字段是私有的 ,我们没有广义的指针模式匹配(尚未)。

The only ways to get at the contained data are Deref (for a & ), and the methods and_then and map (for by-value). 唯一的途径来访问所包含的数据是Deref (对于& ),并且这些方法and_thenmap (通过值)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM