pub enum StructItem<N: TreeNode = SyntaxNode> {
Member(UnboundDecl<N>),
Metadata(MetadataSection<N>),
ParameterMetadata(ParameterMetadataSection<N>),
}Expand description
Represents an item in a struct definition.
Variants§
Member(UnboundDecl<N>)
The item is a member declaration.
Metadata(MetadataSection<N>)
The item is a metadata section.
ParameterMetadata(ParameterMetadataSection<N>)
The item is a parameter meta section.
Implementations§
Source§impl<N: TreeNode> StructItem<N>
impl<N: TreeNode> StructItem<N>
Sourcepub fn can_cast(kind: SyntaxKind) -> bool
pub fn can_cast(kind: SyntaxKind) -> bool
Returns whether or not the given syntax kind can be cast to
StructItem.
Sourcepub fn cast(inner: N) -> Option<Self>
pub fn cast(inner: N) -> Option<Self>
Casts the given node to StructItem.
Returns None if the node cannot be cast.
Sourcepub fn as_unbound_decl(&self) -> Option<&UnboundDecl<N>>
pub fn as_unbound_decl(&self) -> Option<&UnboundDecl<N>>
Attempts to get a reference to the inner UnboundDecl.
- If
selfis aStructItem::Member, then a reference to the innerUnboundDeclis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_unbound_decl(self) -> Option<UnboundDecl<N>>
pub fn into_unbound_decl(self) -> Option<UnboundDecl<N>>
Consumes self and attempts to return the inner UnboundDecl.
- If
selfis aStructItem::Member, then the innerUnboundDeclis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn as_metadata_section(&self) -> Option<&MetadataSection<N>>
pub fn as_metadata_section(&self) -> Option<&MetadataSection<N>>
Attempts to get a reference to the inner MetadataSection.
- If
selfis aStructItem::Metadata, then a reference to the innerMetadataSectionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_metadata_section(self) -> Option<MetadataSection<N>>
pub fn into_metadata_section(self) -> Option<MetadataSection<N>>
Consumes self and attempts to return the inner MetadataSection.
- If
selfis aStructItem::Metadata, then the innerMetadataSectionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn as_parameter_metadata_section(
&self,
) -> Option<&ParameterMetadataSection<N>>
pub fn as_parameter_metadata_section( &self, ) -> Option<&ParameterMetadataSection<N>>
Attempts to get a reference to the inner ParameterMetadataSection.
- If
selfis aStructItem::ParameterMetadata, then a reference to the innerParameterMetadataSectionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_parameter_metadata_section(
self,
) -> Option<ParameterMetadataSection<N>>
pub fn into_parameter_metadata_section( self, ) -> Option<ParameterMetadataSection<N>>
Consumes self and attempts to return the inner
ParameterMetadataSection.
- If
selfis aStructItem::ParameterMetadata, then the innerParameterMetadataSectionis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn child(node: &N) -> Option<Self>
pub fn child(node: &N) -> Option<Self>
Finds the first child that can be cast to a StructItem.
Sourcepub fn children(node: &N) -> impl Iterator<Item = Self> + use<'_, N>
pub fn children(node: &N) -> impl Iterator<Item = Self> + use<'_, N>
Finds all children that can be cast to a StructItem.
Trait Implementations§
Source§impl<N: Clone + TreeNode> Clone for StructItem<N>
impl<N: Clone + TreeNode> Clone for StructItem<N>
Source§fn clone(&self) -> StructItem<N>
fn clone(&self) -> StructItem<N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more