aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r--crates/ra_syntax/src/ast.rs49
1 files changed, 0 insertions, 49 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 0ee9ef199..5a5f56057 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -664,55 +664,6 @@ impl LiteralExpr {
664 } 664 }
665} 665}
666 666
667#[derive(Clone, Debug, PartialEq, Eq, Hash)]
668pub struct FieldPat {
669 pub ident: SmolStr,
670 // FIXME: could we use a regular reference?
671 pub pat: TreeArc<Pat>,
672}
673
674impl FieldPatList {
675 // TODO: try returning an iterator?
676 // FIXME: shouldnt the parser do this? :o
677 pub fn field_pats(&self) -> Vec<FieldPat> {
678 let mut child_iter = self.syntax().children();
679 let mut pats = Vec::new();
680
681 while let Some(node) = child_iter.next() {
682 let kind = node.kind();
683 if kind != IDENT && kind != BIND_PAT {
684 continue;
685 }
686
687 let ident = if let Some(text) = node.leaf_text() {
688 text.clone()
689 } else {
690 SmolStr::new(node.text().to_string())
691 };
692 let mut pat = Pat::cast(node).map(AstNode::to_owned);
693
694 // get pat
695 while let Some(node) = child_iter.next() {
696 if node.kind() == COMMA {
697 break;
698 }
699
700 if let Some(p) = Pat::cast(node) {
701 pat = Some(p.to_owned());
702 }
703 }
704
705 let field_pat = FieldPat {
706 ident: ident,
707 pat: pat.unwrap(),
708 };
709 pats.push(field_pat);
710 }
711
712 pats
713 }
714}
715
716impl BindPat { 667impl BindPat {
717 pub fn is_mutable(&self) -> bool { 668 pub fn is_mutable(&self) -> bool {
718 self.syntax().children().any(|n| n.kind() == MUT_KW) 669 self.syntax().children().any(|n| n.kind() == MUT_KW)