})
}
- /// Checks if the pattern contains any patterns that bind something to
- /// an ident, e.g., `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
- pub fn contains_bindings(&self) -> bool {
- self.satisfies(|p| matches!(p.kind, PatKind::Binding(..)))
- }
-
- /// Checks if the pattern satisfies the given predicate on some sub-pattern.
- fn satisfies(&self, pred: impl Fn(&hir::Pat<'_>) -> bool) -> bool {
- let mut satisfies = false;
- self.walk_short(|p| {
- if pred(p) {
- satisfies = true;
- false // Found one, can short circuit now.
- } else {
- true
- }
- });
- satisfies
- }
-
pub fn simple_ident(&self) -> Option<Ident> {
match self.kind {
PatKind::Binding(