pub enum Decl<N: TreeNode = SyntaxNode> {
Bound(BoundDecl<N>),
Unbound(UnboundDecl<N>),
}Expand description
Represents a declaration in an input section.
Variants§
Implementations§
Source§impl<N: TreeNode> Decl<N>
impl<N: TreeNode> Decl<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
Decl.
Sourcepub fn cast(inner: N) -> Option<Self>
pub fn cast(inner: N) -> Option<Self>
Casts the given node to Decl.
Returns None if the node cannot be cast.
Sourcepub fn env(&self) -> Option<EnvKeyword<N::Token>>
pub fn env(&self) -> Option<EnvKeyword<N::Token>>
Gets the env token, if present.
This may only return a token for task inputs and private declarations (WDL 1.2+).
Sourcepub fn expr(&self) -> Option<Expr<N>>
pub fn expr(&self) -> Option<Expr<N>>
Gets the expression of the declaration.
Returns None for unbound declarations.
Sourcepub fn as_bound_decl(&self) -> Option<&BoundDecl<N>>
pub fn as_bound_decl(&self) -> Option<&BoundDecl<N>>
Attempts to get a reference to the inner BoundDecl.
- If
selfis aDecl::Bound, then a reference to the innerBoundDeclis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_bound_decl(self) -> Option<BoundDecl<N>>
pub fn into_bound_decl(self) -> Option<BoundDecl<N>>
Consumes self and attempts to return the inner BoundDecl.
- If
selfis aDecl::Bound, then the innerBoundDeclis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn unwrap_bound_decl(self) -> BoundDecl<N>
pub fn unwrap_bound_decl(self) -> BoundDecl<N>
Unwraps the declaration into a bound declaration.
§Panics
Panics if the declaration is not a bound declaration.
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 aDecl::Unbound, 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 aDecl::Unbound, then the innerUnboundDeclis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn unwrap_unbound_decl(self) -> UnboundDecl<N>
pub fn unwrap_unbound_decl(self) -> UnboundDecl<N>
Unwraps the declaration into an unbound declaration.
§Panics
Panics if the declaration is not an unbound declaration.