diff options
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index b92cc082e..165b308d1 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -431,6 +431,13 @@ impl StructDef { | |||
431 | } | 431 | } |
432 | 432 | ||
433 | impl EnumVariant { | 433 | impl EnumVariant { |
434 | pub fn parent_enum(&self) -> &EnumDef { | ||
435 | self.syntax() | ||
436 | .parent() | ||
437 | .and_then(|it| it.parent()) | ||
438 | .and_then(EnumDef::cast) | ||
439 | .expect("EnumVariants are always nested in Enums") | ||
440 | } | ||
434 | pub fn flavor(&self) -> StructFlavor { | 441 | pub fn flavor(&self) -> StructFlavor { |
435 | StructFlavor::from_node(self) | 442 | StructFlavor::from_node(self) |
436 | } | 443 | } |