pub struct CppEnumDef { /* private fields */ }Expand description
An enum definition: enum class Color : int { Red, Green };.
Implementations§
Source§impl CppEnumDef
impl CppEnumDef
Sourcepub fn get_body(&self) -> Option<CppSyntaxNode>
pub fn get_body(&self) -> Option<CppSyntaxNode>
The { ... } body holding the enumerators, if this really is an enum definition.
This is what separates enum class E { ... } from an elaborated type specifier such as
enum E x;: both are BuiltinType nodes, and only one of them defines anything.
Sourcepub fn get_enum_keyword(&self) -> Option<CppKeywordToken>
pub fn get_enum_keyword(&self) -> Option<CppKeywordToken>
The enum keyword, if this node really is an enum.
Sourcepub fn get_name(&self) -> Option<CppNameToken>
pub fn get_name(&self) -> Option<CppNameToken>
The enum’s name.
Searched as a subtree: enum class E is parsed as one BuiltinType specifier (the class
belongs to the same specifier as enum), so the name sits one level down.
Sourcepub fn get_enumerators(&self) -> impl Iterator<Item = CppEnumerator>
pub fn get_enumerators(&self) -> impl Iterator<Item = CppEnumerator>
Every enumerator, in order.
The enumerators live inside the body node rather than directly under the enum, so this walks
one level down instead of using children() — which is why it needs first_child_of_kind
rather than child::<N>(): the body is a CompoundStat, the same kind a block statement
uses, so there is no distinct type to ask for.
Trait Implementations§
Source§impl Clone for CppEnumDef
impl Clone for CppEnumDef
Source§impl CppAstNode for CppEnumDef
impl CppAstNode for CppEnumDef
fn syntax(&self) -> &CppSyntaxNode
Source§fn can_cast(kind: CppSyntaxKind) -> bool
fn can_cast(kind: CppSyntaxKind) -> bool
Self? Read morefn cast(syntax: CppSyntaxNode) -> Option<Self>
Source§fn child<N: CppAstNode>(&self) -> Option<N>
fn child<N: CppAstNode>(&self) -> Option<N>
N.Source§fn token<N: CppAstToken>(&self) -> Option<N>
fn token<N: CppAstToken>(&self) -> Option<N>
N.Source§fn token_by_kind(&self, kind: CppTokenKind) -> Option<CppGeneralToken>
fn token_by_kind(&self, kind: CppTokenKind) -> Option<CppGeneralToken>
Source§fn children<N: CppAstNode>(&self) -> CppAstChildren<N> ⓘ
fn children<N: CppAstNode>(&self) -> CppAstChildren<N> ⓘ
N.Source§fn tokens<N: CppAstToken>(&self) -> CppAstTokenChildren<N> ⓘ
fn tokens<N: CppAstToken>(&self) -> CppAstTokenChildren<N> ⓘ
N.Source§fn descendants<N: CppAstNode>(&self) -> impl Iterator<Item = N>
fn descendants<N: CppAstNode>(&self) -> impl Iterator<Item = N>
N.Source§fn walk_descendants<N: CppAstNode>(&self) -> impl Iterator<Item = WalkEvent<N>>
fn walk_descendants<N: CppAstNode>(&self) -> impl Iterator<Item = WalkEvent<N>>
N, with enter/leave events.Source§fn ancestors<N: CppAstNode>(&self) -> impl Iterator<Item = N>
fn ancestors<N: CppAstNode>(&self) -> impl Iterator<Item = N>
N, innermost first.Source§fn get_root(&self) -> CppSyntaxNode
fn get_root(&self) -> CppSyntaxNode
Source§fn get_parent<N: CppAstNode>(&self) -> Option<N>
fn get_parent<N: CppAstNode>(&self) -> Option<N>
N.fn get_position(&self) -> TextSize
fn get_range(&self) -> TextRange
Source§fn get_self_or_ancestor<N: CppAstNode>(&self) -> Option<N>
fn get_self_or_ancestor<N: CppAstNode>(&self) -> Option<N>
N, starting from this node itself.Source§fn get_syntax_id(&self) -> CppSyntaxId
fn get_syntax_id(&self) -> CppSyntaxId
CppSyntaxId.Source§impl Debug for CppEnumDef
impl Debug for CppEnumDef
impl Eq for CppEnumDef
Source§impl Hash for CppEnumDef
impl Hash for CppEnumDef
Source§impl PartialEq for CppEnumDef
impl PartialEq for CppEnumDef
impl StructuralPartialEq for CppEnumDef
Auto Trait Implementations§
impl !RefUnwindSafe for CppEnumDef
impl !Send for CppEnumDef
impl !Sync for CppEnumDef
impl !UnwindSafe for CppEnumDef
impl Freeze for CppEnumDef
impl Unpin for CppEnumDef
impl UnsafeUnpin for CppEnumDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more