diff options
Diffstat (limited to 'crates/syntax/src/ast')
-rw-r--r-- | crates/syntax/src/ast/node_ext.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index 01f580a40..42a7b9c2a 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs | |||
@@ -380,6 +380,15 @@ impl fmt::Display for NameOrNameRef { | |||
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | impl NameOrNameRef { | ||
384 | pub fn text(&self) -> &str { | ||
385 | match self { | ||
386 | NameOrNameRef::Name(name) => name.text(), | ||
387 | NameOrNameRef::NameRef(name_ref) => name_ref.text(), | ||
388 | } | ||
389 | } | ||
390 | } | ||
391 | |||
383 | impl ast::RecordPatField { | 392 | impl ast::RecordPatField { |
384 | pub fn for_field_name_ref(field_name: &ast::NameRef) -> Option<ast::RecordPatField> { | 393 | pub fn for_field_name_ref(field_name: &ast::NameRef) -> Option<ast::RecordPatField> { |
385 | let candidate = field_name.syntax().parent().and_then(ast::RecordPatField::cast)?; | 394 | let candidate = field_name.syntax().parent().and_then(ast::RecordPatField::cast)?; |