mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-20 19:52:48 +00:00
add is_union to structs AST
This commit is contained in:
parent
4ca8331933
commit
765f93b8d8
@ -3,7 +3,12 @@
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::{SmolStr, SyntaxToken, ast::{self, AstNode, children, child_opt}, SyntaxKind::*, SyntaxElement, T};
|
||||
use crate::{
|
||||
SmolStr, SyntaxToken,
|
||||
ast::{self, AstNode, children, child_opt},
|
||||
SyntaxKind::*,
|
||||
SyntaxElement, T,
|
||||
};
|
||||
use ra_parser::SyntaxKind;
|
||||
|
||||
impl ast::Name {
|
||||
@ -196,6 +201,17 @@ impl StructKind<'_> {
|
||||
}
|
||||
|
||||
impl ast::StructDef {
|
||||
pub fn is_union(&self) -> bool {
|
||||
for child in self.syntax().children_with_tokens() {
|
||||
match child.kind() {
|
||||
T![struct] => return false,
|
||||
T![union] => return true,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn kind(&self) -> StructKind {
|
||||
StructKind::from_node(self)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user