diff options
Diffstat (limited to 'crates/syntax/src')
-rw-r--r-- | crates/syntax/src/ast/node_ext.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index bef49238f..df8f98b5b 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs | |||
@@ -608,6 +608,29 @@ impl ast::Visibility { | |||
608 | None => VisibilityKind::Pub, | 608 | None => VisibilityKind::Pub, |
609 | } | 609 | } |
610 | } | 610 | } |
611 | |||
612 | pub fn is_eq_to(&self, other: &Self) -> bool { | ||
613 | match (self.kind(), other.kind()) { | ||
614 | (VisibilityKind::In(this), VisibilityKind::In(other)) => { | ||
615 | stdx::iter_eq_by(this.segments(), other.segments(), |lhs, rhs| { | ||
616 | lhs.kind().zip(rhs.kind()).map_or(false, |it| match it { | ||
617 | (PathSegmentKind::CrateKw, PathSegmentKind::CrateKw) | ||
618 | | (PathSegmentKind::SelfKw, PathSegmentKind::SelfKw) | ||
619 | | (PathSegmentKind::SuperKw, PathSegmentKind::SuperKw) => true, | ||
620 | (PathSegmentKind::Name(lhs), PathSegmentKind::Name(rhs)) => { | ||
621 | lhs.text() == rhs.text() | ||
622 | } | ||
623 | _ => false, | ||
624 | }) | ||
625 | }) | ||
626 | } | ||
627 | (VisibilityKind::PubSelf, VisibilityKind::PubSelf) | ||
628 | | (VisibilityKind::PubSuper, VisibilityKind::PubSuper) | ||
629 | | (VisibilityKind::PubCrate, VisibilityKind::PubCrate) | ||
630 | | (VisibilityKind::Pub, VisibilityKind::Pub) => true, | ||
631 | _ => false, | ||
632 | } | ||
633 | } | ||
611 | } | 634 | } |
612 | 635 | ||
613 | impl ast::LifetimeParam { | 636 | impl ast::LifetimeParam { |