rust-analyzer/crates/ra_syntax/src/ast/generated.rs

9626 lines
248 KiB
Rust
Raw Normal View History

2020-02-07 21:35:34 +00:00
//! Generated file, do not edit by hand, see `xtask/src/codegen`
2020-04-09 08:47:05 +00:00
#[allow(unused_imports)]
2018-10-15 16:55:32 +00:00
use crate::{
2020-04-09 11:00:09 +00:00
ast::{self, support, AstChildren, AstNode, AstToken},
2020-04-09 08:47:05 +00:00
NodeOrToken, SyntaxElement,
2019-08-18 20:36:22 +00:00
SyntaxKind::{self, *},
2020-04-09 08:47:05 +00:00
SyntaxNode, SyntaxToken,
2018-08-09 14:43:39 +00:00
};
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2020-04-09 08:47:05 +00:00
pub struct Semi {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Semi {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Semi {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SEMI => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Comma {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Comma {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Comma {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
COMMA => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LParen {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for LParen {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for LParen {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
L_PAREN => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RParen {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for RParen {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for RParen {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
R_PAREN => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LCurly {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for LCurly {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for LCurly {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
L_CURLY => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RCurly {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for RCurly {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for RCurly {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
R_CURLY => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LBrack {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for LBrack {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for LBrack {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
L_BRACK => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RBrack {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for RBrack {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for RBrack {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
R_BRACK => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LAngle {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for LAngle {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for LAngle {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
L_ANGLE => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RAngle {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for RAngle {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for RAngle {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
R_ANGLE => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct At {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for At {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for At {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
AT => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Pound {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Pound {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Pound {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
POUND => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Tilde {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Tilde {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Tilde {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TILDE => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Question {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Question {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Question {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
QUESTION => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Dollar {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Dollar {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Dollar {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DOLLAR => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Amp {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Amp {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Amp {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
AMP => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Pipe {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Pipe {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Pipe {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PIPE => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Plus {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Plus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Plus {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PLUS => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Star {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Star {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Star {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STAR => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Slash {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Slash {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Slash {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SLASH => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Caret {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Caret {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Caret {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CARET => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Percent {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Percent {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Percent {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PERCENT => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Underscore {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Underscore {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Underscore {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
UNDERSCORE => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Dot {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Dot {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Dot {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DOT => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Dotdot {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Dotdot {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Dotdot {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DOTDOT => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Dotdotdot {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Dotdotdot {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Dotdotdot {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DOTDOTDOT => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Dotdoteq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Dotdoteq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Dotdoteq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DOTDOTEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Colon {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Colon {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Colon {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
COLON => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Coloncolon {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Coloncolon {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Coloncolon {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
COLONCOLON => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Eq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Eq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Eq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
EQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Eqeq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Eqeq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Eqeq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
EQEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FatArrow {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for FatArrow {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for FatArrow {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FAT_ARROW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Excl {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Excl {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Excl {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
EXCL => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Neq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Neq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Neq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
NEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Minus {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Minus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Minus {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MINUS => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ThinArrow {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ThinArrow {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ThinArrow {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
THIN_ARROW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Lteq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Lteq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Lteq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LTEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Gteq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Gteq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Gteq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
GTEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Pluseq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Pluseq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Pluseq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PLUSEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Minuseq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Minuseq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Minuseq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MINUSEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Pipeeq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Pipeeq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Pipeeq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PIPEEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Ampeq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Ampeq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Ampeq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
AMPEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Careteq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Careteq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Careteq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CARETEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Slasheq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Slasheq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Slasheq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SLASHEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Stareq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Stareq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Stareq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STAREQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Percenteq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Percenteq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Percenteq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PERCENTEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Ampamp {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Ampamp {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Ampamp {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
AMPAMP => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Pipepipe {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Pipepipe {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Pipepipe {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PIPEPIPE => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Shl {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Shl {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Shl {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SHL => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Shr {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Shr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Shr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SHR => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Shleq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Shleq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Shleq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SHLEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Shreq {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Shreq {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Shreq {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SHREQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AsKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for AsKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for AsKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
AS_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AsyncKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for AsyncKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for AsyncKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ASYNC_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AwaitKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for AwaitKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for AwaitKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
AWAIT_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BoxKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for BoxKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for BoxKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BOX_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BreakKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for BreakKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for BreakKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BREAK_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ConstKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ConstKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ConstKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CONST_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ContinueKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ContinueKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ContinueKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CONTINUE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CrateKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for CrateKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for CrateKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CRATE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DynKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for DynKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for DynKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DYN_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ElseKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ElseKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ElseKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ELSE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct EnumKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for EnumKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for EnumKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ENUM_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ExternKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ExternKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ExternKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
EXTERN_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FalseKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for FalseKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for FalseKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FALSE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FnKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for FnKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for FnKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FN_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ForKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ForKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ForKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FOR_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct IfKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for IfKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for IfKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
IF_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ImplKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ImplKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ImplKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
IMPL_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct InKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for InKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for InKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
IN_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LetKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for LetKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for LetKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LET_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LoopKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for LoopKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for LoopKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LOOP_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MacroKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for MacroKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for MacroKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MACRO_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MatchKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for MatchKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for MatchKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MATCH_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ModKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ModKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ModKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MOD_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MoveKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for MoveKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for MoveKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MOVE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MutKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for MutKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for MutKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MUT_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PubKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for PubKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for PubKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PUB_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RefKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for RefKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for RefKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
REF_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ReturnKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ReturnKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ReturnKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RETURN_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SelfKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for SelfKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for SelfKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SELF_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StaticKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for StaticKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for StaticKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STATIC_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StructKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for StructKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for StructKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STRUCT_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SuperKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for SuperKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for SuperKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SUPER_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TraitKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for TraitKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for TraitKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TRAIT_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TrueKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for TrueKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for TrueKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TRUE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TryKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for TryKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for TryKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TRY_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for TypeKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for TypeKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TYPE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UnsafeKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for UnsafeKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for UnsafeKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
UNSAFE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UseKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for UseKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for UseKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
USE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct WhereKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for WhereKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for WhereKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
WHERE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct WhileKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for WhileKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for WhileKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
WHILE_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AutoKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for AutoKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for AutoKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
AUTO_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DefaultKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for DefaultKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for DefaultKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DEFAULT_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ExistentialKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ExistentialKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ExistentialKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
EXISTENTIAL_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UnionKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for UnionKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for UnionKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
UNION_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2020-04-09 11:00:09 +00:00
pub struct RawKw {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for RawKw {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for RawKw {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RAW_KW => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2020-04-09 08:47:05 +00:00
pub struct IntNumber {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for IntNumber {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for IntNumber {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
INT_NUMBER => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FloatNumber {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for FloatNumber {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for FloatNumber {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FLOAT_NUMBER => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Char {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Char {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Char {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CHAR => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Byte {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Byte {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Byte {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BYTE => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct String {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for String {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for String {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STRING => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RawString {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for RawString {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for RawString {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RAW_STRING => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ByteString {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for ByteString {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for ByteString {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BYTE_STRING => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RawByteString {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for RawByteString {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for RawByteString {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RAW_BYTE_STRING => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Error {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Error {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ERROR => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Ident {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Ident {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Ident {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
IDENT => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Whitespace {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Whitespace {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Whitespace {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
WHITESPACE => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Lifetime {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Lifetime {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Lifetime {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LIFETIME => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Comment {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Comment {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Comment {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
COMMENT => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Shebang {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Shebang {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Shebang {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SHEBANG => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LDollar {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for LDollar {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for LDollar {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
L_DOLLAR => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RDollar {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for RDollar {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for RDollar {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
R_DOLLAR => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken {
&self.syntax
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SourceFile {
2019-02-01 23:18:10 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for SourceFile {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for SourceFile {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SOURCE_FILE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2019-02-01 23:18:10 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
2019-02-01 23:18:10 +00:00
}
impl ast::ModuleItemOwner for SourceFile {}
impl ast::FnDefOwner for SourceFile {}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for SourceFile {}
impl SourceFile {
pub fn modules(&self) -> AstChildren<Module> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FnDef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-28 20:59:57 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for FnDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for FnDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FN_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-28 20:59:57 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::VisibilityOwner for FnDef {}
impl ast::NameOwner for FnDef {}
impl ast::TypeParamsOwner for FnDef {}
impl ast::DocCommentsOwner for FnDef {}
impl ast::AttrsOwner for FnDef {}
impl FnDef {
2020-04-09 11:00:09 +00:00
pub fn abi(&self) -> Option<Abi> {
support::child(&self.syntax)
}
pub fn const_kw(&self) -> Option<ConstKw> {
support::token(&self.syntax)
}
pub fn default_kw(&self) -> Option<DefaultKw> {
support::token(&self.syntax)
}
pub fn async_kw(&self) -> Option<AsyncKw> {
support::token(&self.syntax)
}
pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
support::token(&self.syntax)
}
pub fn fn_kw(&self) -> Option<FnKw> {
support::token(&self.syntax)
}
pub fn param_list(&self) -> Option<ParamList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn ret_type(&self) -> Option<RetType> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn body(&self) -> Option<BlockExpr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RetType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RetType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RetType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RET_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl RetType {
2020-04-09 11:00:09 +00:00
pub fn thin_arrow(&self) -> Option<ThinArrow> {
support::token(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-01-13 13:46:10 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StructDef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for StructDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for StructDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STRUCT_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::VisibilityOwner for StructDef {}
impl ast::NameOwner for StructDef {}
impl ast::TypeParamsOwner for StructDef {}
impl ast::AttrsOwner for StructDef {}
impl ast::DocCommentsOwner for StructDef {}
2020-04-09 11:00:09 +00:00
impl StructDef {
pub fn struct_kw(&self) -> Option<StructKw> {
support::token(&self.syntax)
}
pub fn field_def_list(&self) -> Option<FieldDefList> {
support::child(&self.syntax)
}
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UnionDef {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for UnionDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for UnionDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
UNION_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::VisibilityOwner for UnionDef {}
impl ast::NameOwner for UnionDef {}
impl ast::TypeParamsOwner for UnionDef {}
impl ast::AttrsOwner for UnionDef {}
impl ast::DocCommentsOwner for UnionDef {}
impl UnionDef {
2020-04-09 11:00:09 +00:00
pub fn union_kw(&self) -> Option<UnionKw> {
support::token(&self.syntax)
}
pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldDefList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RecordFieldDefList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RecordFieldDefList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_DEF_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-16 09:51:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl RecordFieldDefList {
2020-04-09 11:00:09 +00:00
pub fn l_curly(&self) -> Option<LCurly> {
support::token(&self.syntax)
}
pub fn fields(&self) -> AstChildren<RecordFieldDef> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_curly(&self) -> Option<RCurly> {
support::token(&self.syntax)
2019-09-29 20:44:33 +00:00
}
}
2019-07-20 10:35:49 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldDef {
pub(crate) syntax: SyntaxNode,
2019-09-29 20:44:33 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RecordFieldDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RecordFieldDef {
2019-09-29 20:44:33 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_DEF => true,
2019-09-29 20:44:33 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
2019-09-29 20:44:33 +00:00
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-09-29 20:44:33 +00:00
}
}
impl ast::VisibilityOwner for RecordFieldDef {}
impl ast::NameOwner for RecordFieldDef {}
impl ast::AttrsOwner for RecordFieldDef {}
impl ast::DocCommentsOwner for RecordFieldDef {}
impl ast::TypeAscriptionOwner for RecordFieldDef {}
impl RecordFieldDef {}
2019-07-20 10:35:49 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TupleFieldDefList {
2019-07-20 10:35:49 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TupleFieldDefList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TupleFieldDefList {
2019-07-20 10:35:49 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_FIELD_DEF_LIST => true,
2019-07-20 10:35:49 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-20 10:35:49 +00:00
}
}
impl TupleFieldDefList {
2020-04-09 11:00:09 +00:00
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
pub fn fields(&self) -> AstChildren<TupleFieldDef> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
2019-07-20 10:35:49 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TupleFieldDef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TupleFieldDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TupleFieldDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_FIELD_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::VisibilityOwner for TupleFieldDef {}
impl ast::AttrsOwner for TupleFieldDef {}
impl TupleFieldDef {
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct EnumDef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for EnumDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for EnumDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ENUM_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::VisibilityOwner for EnumDef {}
impl ast::NameOwner for EnumDef {}
impl ast::TypeParamsOwner for EnumDef {}
impl ast::AttrsOwner for EnumDef {}
impl ast::DocCommentsOwner for EnumDef {}
impl EnumDef {
2020-04-09 11:00:09 +00:00
pub fn enum_kw(&self) -> Option<EnumKw> {
support::token(&self.syntax)
}
pub fn variant_list(&self) -> Option<EnumVariantList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct EnumVariantList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for EnumVariantList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for EnumVariantList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ENUM_VARIANT_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl EnumVariantList {
2020-04-09 11:00:09 +00:00
pub fn l_curly(&self) -> Option<LCurly> {
support::token(&self.syntax)
}
pub fn variants(&self) -> AstChildren<EnumVariant> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_curly(&self) -> Option<RCurly> {
support::token(&self.syntax)
2018-08-26 09:09:28 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct EnumVariant {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for EnumVariant {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for EnumVariant {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ENUM_VARIANT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::VisibilityOwner for EnumVariant {}
impl ast::NameOwner for EnumVariant {}
impl ast::DocCommentsOwner for EnumVariant {}
impl ast::AttrsOwner for EnumVariant {}
impl EnumVariant {
2020-04-09 11:00:09 +00:00
pub fn field_def_list(&self) -> Option<FieldDefList> {
support::child(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TraitDef {
2019-09-11 15:53:41 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TraitDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TraitDef {
2019-09-11 15:53:41 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TRAIT_DEF => true,
2019-09-11 15:53:41 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::VisibilityOwner for TraitDef {}
impl ast::NameOwner for TraitDef {}
impl ast::AttrsOwner for TraitDef {}
impl ast::DocCommentsOwner for TraitDef {}
impl ast::TypeParamsOwner for TraitDef {}
impl ast::TypeBoundsOwner for TraitDef {}
impl TraitDef {
2020-04-09 11:00:09 +00:00
pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
support::token(&self.syntax)
}
pub fn auto_kw(&self) -> Option<AutoKw> {
support::token(&self.syntax)
}
pub fn trait_kw(&self) -> Option<TraitKw> {
support::token(&self.syntax)
}
pub fn item_list(&self) -> Option<ItemList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-09-11 15:53:41 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Module {
2019-08-23 20:04:58 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Module {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Module {
2019-08-23 20:04:58 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MODULE => true,
2019-08-23 20:04:58 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::VisibilityOwner for Module {}
impl ast::NameOwner for Module {}
impl ast::AttrsOwner for Module {}
impl ast::DocCommentsOwner for Module {}
impl Module {
2020-04-09 11:00:09 +00:00
pub fn mod_kw(&self) -> Option<ModKw> {
support::token(&self.syntax)
}
pub fn item_list(&self) -> Option<ItemList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
2019-08-23 20:04:58 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ItemList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ItemList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ItemList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ITEM_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::FnDefOwner for ItemList {}
impl ast::ModuleItemOwner for ItemList {}
impl ItemList {
2020-04-09 11:00:09 +00:00
pub fn l_curly(&self) -> Option<LCurly> {
support::token(&self.syntax)
}
pub fn impl_items(&self) -> AstChildren<ImplItem> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_curly(&self) -> Option<RCurly> {
support::token(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ConstDef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ConstDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ConstDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CONST_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::VisibilityOwner for ConstDef {}
impl ast::NameOwner for ConstDef {}
impl ast::TypeParamsOwner for ConstDef {}
impl ast::AttrsOwner for ConstDef {}
impl ast::DocCommentsOwner for ConstDef {}
impl ast::TypeAscriptionOwner for ConstDef {}
impl ConstDef {
2020-04-09 11:00:09 +00:00
pub fn default_kw(&self) -> Option<DefaultKw> {
support::token(&self.syntax)
}
pub fn const_kw(&self) -> Option<ConstKw> {
support::token(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn body(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
2018-08-28 20:59:57 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StaticDef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for StaticDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for StaticDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STATIC_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::VisibilityOwner for StaticDef {}
impl ast::NameOwner for StaticDef {}
impl ast::TypeParamsOwner for StaticDef {}
impl ast::AttrsOwner for StaticDef {}
impl ast::DocCommentsOwner for StaticDef {}
impl ast::TypeAscriptionOwner for StaticDef {}
impl StaticDef {
2020-04-09 11:00:09 +00:00
pub fn static_kw(&self) -> Option<StaticKw> {
support::token(&self.syntax)
}
pub fn mut_kw(&self) -> Option<MutKw> {
support::token(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn body(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
2018-12-20 20:56:28 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeAliasDef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TypeAliasDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TypeAliasDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TYPE_ALIAS_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-27 09:22:09 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::VisibilityOwner for TypeAliasDef {}
impl ast::NameOwner for TypeAliasDef {}
impl ast::TypeParamsOwner for TypeAliasDef {}
impl ast::AttrsOwner for TypeAliasDef {}
impl ast::DocCommentsOwner for TypeAliasDef {}
impl ast::TypeBoundsOwner for TypeAliasDef {}
impl TypeAliasDef {
2020-04-09 11:00:09 +00:00
pub fn default_kw(&self) -> Option<DefaultKw> {
support::token(&self.syntax)
}
pub fn type_kw(&self) -> Option<TypeKw> {
support::token(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
2018-08-27 09:22:09 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2020-02-29 20:24:40 +00:00
pub struct ImplDef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-11 08:03:22 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ImplDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
2020-02-29 20:24:40 +00:00
impl AstNode for ImplDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
2020-02-29 20:24:40 +00:00
IMPL_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-11 08:03:22 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-02-29 20:24:40 +00:00
impl ast::TypeParamsOwner for ImplDef {}
impl ast::AttrsOwner for ImplDef {}
impl ImplDef {
2020-04-09 11:00:09 +00:00
pub fn default_kw(&self) -> Option<DefaultKw> {
support::token(&self.syntax)
}
pub fn const_kw(&self) -> Option<ConstKw> {
support::token(&self.syntax)
}
pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
support::token(&self.syntax)
}
pub fn impl_kw(&self) -> Option<ImplKw> {
support::token(&self.syntax)
}
pub fn excl(&self) -> Option<Excl> {
support::token(&self.syntax)
}
pub fn for_kw(&self) -> Option<ForKw> {
support::token(&self.syntax)
}
pub fn item_list(&self) -> Option<ItemList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ParenType {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ParenType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ParenType {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PAREN_TYPE => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ParenType {
2020-04-09 11:00:09 +00:00
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TupleType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TupleType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TupleType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl TupleType {
2020-04-09 11:00:09 +00:00
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
pub fn fields(&self) -> AstChildren<TypeRef> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NeverType {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for NeverType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for NeverType {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
NEVER_TYPE => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
2020-04-09 11:00:09 +00:00
impl NeverType {
pub fn excl(&self) -> Option<Excl> {
support::token(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PathType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for PathType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for PathType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PATH_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl PathType {
pub fn path(&self) -> Option<Path> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PointerType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for PointerType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for PointerType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
POINTER_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-11 07:56:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl PointerType {
2020-04-09 11:00:09 +00:00
pub fn star(&self) -> Option<Star> {
support::token(&self.syntax)
}
pub fn const_kw(&self) -> Option<ConstKw> {
support::token(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ArrayType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ArrayType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ArrayType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ARRAY_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ArrayType {
2020-04-09 11:00:09 +00:00
pub fn l_brack(&self) -> Option<LBrack> {
support::token(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
}
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn r_brack(&self) -> Option<RBrack> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SliceType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for SliceType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for SliceType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SLICE_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl SliceType {
2020-04-09 11:00:09 +00:00
pub fn l_brack(&self) -> Option<LBrack> {
support::token(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn r_brack(&self) -> Option<RBrack> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ReferenceType {
pub(crate) syntax: SyntaxNode,
2019-02-24 13:57:05 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ReferenceType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ReferenceType {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
REFERENCE_TYPE => true,
_ => false,
}
2019-08-18 20:36:22 +00:00
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
2019-08-18 20:36:22 +00:00
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
impl ReferenceType {
2020-04-09 11:00:09 +00:00
pub fn amp(&self) -> Option<Amp> {
support::token(&self.syntax)
}
pub fn lifetime(&self) -> Option<Lifetime> {
support::token(&self.syntax)
}
pub fn mut_kw(&self) -> Option<MutKw> {
support::token(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PlaceholderType {
pub(crate) syntax: SyntaxNode,
2019-02-24 13:57:05 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for PlaceholderType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for PlaceholderType {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PLACEHOLDER_TYPE => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-01-07 13:16:02 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl PlaceholderType {
pub fn underscore(&self) -> Option<Underscore> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FnPointerType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for FnPointerType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for FnPointerType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FN_POINTER_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-27 07:01:31 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl FnPointerType {
2020-04-09 11:00:09 +00:00
pub fn abi(&self) -> Option<Abi> {
support::child(&self.syntax)
}
pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
support::token(&self.syntax)
}
pub fn fn_kw(&self) -> Option<FnKw> {
support::token(&self.syntax)
}
pub fn param_list(&self) -> Option<ParamList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn ret_type(&self) -> Option<RetType> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ForType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ForType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ForType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FOR_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-28 08:12:42 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ForType {
2020-04-09 11:00:09 +00:00
pub fn for_kw(&self) -> Option<ForKw> {
support::token(&self.syntax)
}
pub fn type_param_list(&self) -> Option<TypeParamList> {
support::child(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ImplTraitType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ImplTraitType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ImplTraitType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
IMPL_TRAIT_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::TypeBoundsOwner for ImplTraitType {}
2020-04-09 11:00:09 +00:00
impl ImplTraitType {
pub fn impl_kw(&self) -> Option<ImplKw> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DynTraitType {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for DynTraitType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for DynTraitType {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DYN_TRAIT_TYPE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-09 14:43:39 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::TypeBoundsOwner for DynTraitType {}
2020-04-09 11:00:09 +00:00
impl DynTraitType {
pub fn dyn_kw(&self) -> Option<DynKw> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TupleExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TupleExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TupleExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for TupleExpr {}
impl TupleExpr {
2020-04-09 11:00:09 +00:00
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
pub fn exprs(&self) -> AstChildren<Expr> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ArrayExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ArrayExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ArrayExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ARRAY_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for ArrayExpr {}
impl ArrayExpr {
2020-04-09 11:00:09 +00:00
pub fn l_brack(&self) -> Option<LBrack> {
support::token(&self.syntax)
}
pub fn exprs(&self) -> AstChildren<Expr> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
}
pub fn r_brack(&self) -> Option<RBrack> {
support::token(&self.syntax)
2018-08-27 19:03:19 +00:00
}
2018-08-27 09:22:09 +00:00
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ParenExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ParenExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ParenExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PAREN_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for ParenExpr {}
impl ParenExpr {
2020-04-09 11:00:09 +00:00
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PathExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for PathExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for PathExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PATH_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl PathExpr {
pub fn path(&self) -> Option<Path> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LambdaExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for LambdaExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for LambdaExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LAMBDA_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 08:20:09 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for LambdaExpr {}
impl LambdaExpr {
2020-04-09 11:00:09 +00:00
pub fn static_kw(&self) -> Option<StaticKw> {
support::token(&self.syntax)
}
pub fn async_kw(&self) -> Option<AsyncKw> {
support::token(&self.syntax)
}
pub fn move_kw(&self) -> Option<MoveKw> {
support::token(&self.syntax)
}
pub fn param_list(&self) -> Option<ParamList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn ret_type(&self) -> Option<RetType> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn body(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct IfExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for IfExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for IfExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
IF_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for IfExpr {}
impl IfExpr {
2020-04-09 11:00:09 +00:00
pub fn if_kw(&self) -> Option<IfKw> {
support::token(&self.syntax)
}
pub fn condition(&self) -> Option<Condition> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LoopExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for LoopExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for LoopExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LOOP_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for LoopExpr {}
impl ast::LoopBodyOwner for LoopExpr {}
2020-04-09 11:00:09 +00:00
impl LoopExpr {
pub fn loop_kw(&self) -> Option<LoopKw> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TryBlockExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TryBlockExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TryBlockExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TRY_BLOCK_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-09-03 12:10:06 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for TryBlockExpr {}
impl TryBlockExpr {
2020-04-09 11:00:09 +00:00
pub fn try_kw(&self) -> Option<TryKw> {
support::token(&self.syntax)
}
pub fn body(&self) -> Option<BlockExpr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ForExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ForExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ForExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FOR_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for ForExpr {}
impl ast::LoopBodyOwner for ForExpr {}
impl ForExpr {
2020-04-09 11:00:09 +00:00
pub fn for_kw(&self) -> Option<ForKw> {
support::token(&self.syntax)
}
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn in_kw(&self) -> Option<InKw> {
support::token(&self.syntax)
}
pub fn iterable(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct WhileExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for WhileExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for WhileExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
WHILE_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for WhileExpr {}
impl ast::LoopBodyOwner for WhileExpr {}
impl WhileExpr {
2020-04-09 11:00:09 +00:00
pub fn while_kw(&self) -> Option<WhileKw> {
support::token(&self.syntax)
}
pub fn condition(&self) -> Option<Condition> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-08-28 20:59:57 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ContinueExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ContinueExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ContinueExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CONTINUE_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for ContinueExpr {}
impl ContinueExpr {
pub fn continue_kw(&self) -> Option<ContinueKw> {
support::token(&self.syntax)
}
pub fn lifetime(&self) -> Option<Lifetime> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BreakExpr {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for BreakExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for BreakExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BREAK_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for BreakExpr {}
impl BreakExpr {
2020-04-09 11:00:09 +00:00
pub fn break_kw(&self) -> Option<BreakKw> {
support::token(&self.syntax)
}
pub fn lifetime(&self) -> Option<Lifetime> {
support::token(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Label {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-28 20:59:57 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Label {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Label {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LABEL => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-28 20:59:57 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl Label {
pub fn lifetime(&self) -> Option<Lifetime> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BlockExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for BlockExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for BlockExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BLOCK_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-28 11:21:37 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for BlockExpr {}
impl BlockExpr {
2020-04-09 11:00:09 +00:00
pub fn label(&self) -> Option<Label> {
support::child(&self.syntax)
}
pub fn unsafe_kw(&self) -> Option<UnsafeKw> {
support::token(&self.syntax)
}
pub fn block(&self) -> Option<Block> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ReturnExpr {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ReturnExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ReturnExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RETURN_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for ReturnExpr {}
impl ReturnExpr {
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CallExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for CallExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for CallExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CALL_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::ArgListOwner for CallExpr {}
impl CallExpr {
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MethodCallExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-12-28 10:27:30 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for MethodCallExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MethodCallExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
METHOD_CALL_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-12-28 10:27:30 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for MethodCallExpr {}
impl ast::ArgListOwner for MethodCallExpr {}
impl MethodCallExpr {
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn dot(&self) -> Option<Dot> {
support::token(&self.syntax)
2018-12-28 10:27:30 +00:00
}
pub fn name_ref(&self) -> Option<NameRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn type_arg_list(&self) -> Option<TypeArgList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-12-28 13:59:58 +00:00
}
2018-12-28 10:27:30 +00:00
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct IndexExpr {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for IndexExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for IndexExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
INDEX_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for IndexExpr {}
impl IndexExpr {
pub fn l_brack(&self) -> Option<LBrack> {
support::token(&self.syntax)
}
pub fn r_brack(&self) -> Option<RBrack> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FieldExpr {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for FieldExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for FieldExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FIELD_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for FieldExpr {}
impl FieldExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn dot(&self) -> Option<Dot> {
support::token(&self.syntax)
}
pub fn name_ref(&self) -> Option<NameRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AwaitExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for AwaitExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for AwaitExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
AWAIT_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for AwaitExpr {}
impl AwaitExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn dot(&self) -> Option<Dot> {
support::token(&self.syntax)
}
pub fn await_kw(&self) -> Option<AwaitKw> {
support::token(&self.syntax)
2018-09-02 22:51:46 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TryExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TryExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TryExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TRY_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for TryExpr {}
impl TryExpr {
2020-04-09 11:00:09 +00:00
pub fn try_kw(&self) -> Option<TryKw> {
support::token(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CastExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for CastExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for CastExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CAST_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for CastExpr {}
impl CastExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn as_kw(&self) -> Option<AsKw> {
support::token(&self.syntax)
2018-09-02 22:51:46 +00:00
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-09-02 22:51:46 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RefExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RefExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RefExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
REF_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for RefExpr {}
impl RefExpr {
2020-04-09 11:00:09 +00:00
pub fn amp(&self) -> Option<Amp> {
support::token(&self.syntax)
}
pub fn raw_kw(&self) -> Option<RawKw> {
support::token(&self.syntax)
}
pub fn mut_kw(&self) -> Option<MutKw> {
support::token(&self.syntax)
}
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-01-28 22:06:11 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PrefixExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for PrefixExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for PrefixExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PREFIX_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for PrefixExpr {}
impl PrefixExpr {
2020-04-09 11:00:09 +00:00
pub fn prefix_op(&self) -> Option<PrefixOp> {
support::token(&self.syntax)
}
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-09-02 23:01:43 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BoxExpr {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-11 08:03:22 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for BoxExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for BoxExpr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BOX_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-11 08:03:22 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for BoxExpr {}
impl BoxExpr {
2020-04-09 11:00:09 +00:00
pub fn box_kw(&self) -> Option<BoxKw> {
support::token(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-08-21 15:30:10 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RangeExpr {
pub(crate) syntax: SyntaxNode,
2019-01-07 13:16:02 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RangeExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RangeExpr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RANGE_EXPR => true,
_ => false,
}
2019-08-18 20:36:22 +00:00
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
2019-11-25 14:30:50 +00:00
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for RangeExpr {}
impl RangeExpr {
pub fn range_op(&self) -> Option<RangeOp> {
support::token(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BinExpr {
pub(crate) syntax: SyntaxNode,
2019-02-24 13:57:05 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for BinExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for BinExpr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BIN_EXPR => true,
_ => false,
}
2019-08-18 20:36:22 +00:00
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
2019-08-18 20:36:22 +00:00
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for BinExpr {}
impl BinExpr {
pub fn bin_op(&self) -> Option<BinOp> {
support::token(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Literal {
pub(crate) syntax: SyntaxNode,
2019-02-24 13:57:05 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Literal {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Literal {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LITERAL => true,
_ => false,
}
2019-08-18 20:36:22 +00:00
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
2019-08-18 20:36:22 +00:00
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2020-04-09 11:00:09 +00:00
impl Literal {
pub fn literal_token(&self) -> Option<LiteralToken> {
support::token(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MatchExpr {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for MatchExpr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MatchExpr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MATCH_EXPR => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for MatchExpr {}
impl MatchExpr {
2020-04-09 11:00:09 +00:00
pub fn match_kw(&self) -> Option<MatchKw> {
support::token(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn match_arm_list(&self) -> Option<MatchArmList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-01-07 13:16:02 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MatchArmList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for MatchArmList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MatchArmList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MATCH_ARM_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-09 14:43:39 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::AttrsOwner for MatchArmList {}
impl MatchArmList {
2020-04-09 11:00:09 +00:00
pub fn l_curly(&self) -> Option<LCurly> {
support::token(&self.syntax)
}
pub fn arms(&self) -> AstChildren<MatchArm> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_curly(&self) -> Option<RCurly> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MatchArm {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-13 13:35:17 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for MatchArm {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MatchArm {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MATCH_ARM => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-13 13:35:17 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::AttrsOwner for MatchArm {}
impl MatchArm {
2020-02-09 18:57:01 +00:00
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn guard(&self) -> Option<MatchGuard> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn fat_arrow(&self) -> Option<FatArrow> {
support::token(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MatchGuard {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for MatchGuard {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MatchGuard {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MATCH_GUARD => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl MatchGuard {
2020-04-09 11:00:09 +00:00
pub fn if_kw(&self) -> Option<IfKw> {
support::token(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-08-18 20:36:22 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordLit {
pub(crate) syntax: SyntaxNode,
2019-11-25 14:30:50 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RecordLit {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RecordLit {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_LIT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl RecordLit {
pub fn path(&self) -> Option<Path> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn record_field_list(&self) -> Option<RecordFieldList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-08-14 10:33:44 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RecordFieldList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RecordFieldList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl RecordFieldList {
2020-04-09 11:00:09 +00:00
pub fn l_curly(&self) -> Option<LCurly> {
support::token(&self.syntax)
}
pub fn fields(&self) -> AstChildren<RecordField> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn dotdot(&self) -> Option<Dotdot> {
support::token(&self.syntax)
}
pub fn spread(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn r_curly(&self) -> Option<RCurly> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordField {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RecordField {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RecordField {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for RecordField {}
impl RecordField {
pub fn name_ref(&self) -> Option<NameRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn colon(&self) -> Option<Colon> {
support::token(&self.syntax)
2018-08-26 09:09:28 +00:00
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-08-31 13:30:42 +00:00
}
2018-08-26 09:09:28 +00:00
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2020-02-09 18:57:01 +00:00
pub struct OrPat {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for OrPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
2020-02-09 18:57:01 +00:00
impl AstNode for OrPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
OR_PAT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl OrPat {
pub fn pats(&self) -> AstChildren<Pat> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
2020-02-09 18:57:01 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ParenPat {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ParenPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
2020-02-09 18:57:01 +00:00
impl AstNode for ParenPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PAREN_PAT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ParenPat {
2020-04-09 11:00:09 +00:00
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
2020-02-09 18:57:01 +00:00
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
2020-02-09 18:57:01 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RefPat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RefPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RefPat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
REF_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl RefPat {
2020-04-09 11:00:09 +00:00
pub fn amp(&self) -> Option<Amp> {
support::token(&self.syntax)
}
pub fn mut_kw(&self) -> Option<MutKw> {
support::token(&self.syntax)
}
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-12-20 20:56:28 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BoxPat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for BoxPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for BoxPat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BOX_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl BoxPat {
2020-04-09 11:00:09 +00:00
pub fn box_kw(&self) -> Option<BoxKw> {
support::token(&self.syntax)
}
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BindPat {
pub(crate) syntax: SyntaxNode,
2019-01-07 13:16:02 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for BindPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for BindPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BIND_PAT => true,
_ => false,
}
2019-08-18 20:36:22 +00:00
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
2019-08-23 20:04:58 +00:00
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for BindPat {}
impl ast::NameOwner for BindPat {}
impl BindPat {
2020-04-09 11:00:09 +00:00
pub fn ref_kw(&self) -> Option<RefKw> {
support::token(&self.syntax)
}
pub fn mut_kw(&self) -> Option<MutKw> {
support::token(&self.syntax)
}
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PlaceholderPat {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for PlaceholderPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for PlaceholderPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PLACEHOLDER_PAT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2018-08-26 09:09:28 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl PlaceholderPat {
pub fn underscore(&self) -> Option<Underscore> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DotDotPat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-30 17:03:18 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for DotDotPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for DotDotPat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DOT_DOT_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-30 17:03:18 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl DotDotPat {
pub fn dotdot(&self) -> Option<Dotdot> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PathPat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for PathPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for PathPat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PATH_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl PathPat {
2019-07-18 16:23:05 +00:00
pub fn path(&self) -> Option<Path> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SlicePat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for SlicePat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for SlicePat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SLICE_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl SlicePat {
2020-04-09 11:00:09 +00:00
pub fn l_brack(&self) -> Option<LBrack> {
support::token(&self.syntax)
}
pub fn args(&self) -> AstChildren<Pat> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_brack(&self) -> Option<RBrack> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RangePat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RangePat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RangePat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RANGE_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-30 17:37:33 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl RangePat {
pub fn range_separator(&self) -> Option<RangeSeparator> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LiteralPat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for LiteralPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for LiteralPat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LITERAL_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl LiteralPat {
pub fn literal(&self) -> Option<Literal> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-12-22 21:17:55 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MacroPat {
pub(crate) syntax: SyntaxNode,
}
impl std::fmt::Display for MacroPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MacroPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MACRO_PAT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl MacroPat {
pub fn macro_call(&self) -> Option<MacroCall> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordPat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RecordPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RecordPat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl RecordPat {
pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn path(&self) -> Option<Path> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldPatList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RecordFieldPatList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RecordFieldPatList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_PAT_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl RecordFieldPatList {
2020-04-09 11:00:09 +00:00
pub fn l_curly(&self) -> Option<LCurly> {
support::token(&self.syntax)
}
pub fn pats(&self) -> AstChildren<RecordInnerPat> {
support::children(&self.syntax)
}
pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn bind_pats(&self) -> AstChildren<BindPat> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn dotdot(&self) -> Option<Dotdot> {
support::token(&self.syntax)
}
pub fn r_curly(&self) -> Option<RCurly> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordFieldPat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for RecordFieldPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RecordFieldPat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for RecordFieldPat {}
impl ast::NameOwner for RecordFieldPat {}
impl RecordFieldPat {
2020-04-09 11:00:09 +00:00
pub fn colon(&self) -> Option<Colon> {
support::token(&self.syntax)
}
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TupleStructPat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TupleStructPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TupleStructPat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_STRUCT_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl TupleStructPat {
pub fn path(&self) -> Option<Path> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
pub fn args(&self) -> AstChildren<Pat> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TuplePat {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TuplePat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TuplePat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl TuplePat {
2020-04-09 11:00:09 +00:00
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
pub fn args(&self) -> AstChildren<Pat> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
}
}
2019-08-23 12:55:21 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Visibility {
2019-08-23 12:55:21 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Visibility {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Visibility {
2019-08-23 12:55:21 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
VISIBILITY => true,
2019-08-23 12:55:21 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
2020-04-09 11:00:09 +00:00
impl Visibility {
pub fn pub_kw(&self) -> Option<PubKw> {
support::token(&self.syntax)
}
pub fn super_kw(&self) -> Option<SuperKw> {
support::token(&self.syntax)
}
pub fn self_kw(&self) -> Option<SelfKw> {
support::token(&self.syntax)
}
pub fn crate_kw(&self) -> Option<CrateKw> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Name {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Name {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Name {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
NAME => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl Name {
pub fn ident(&self) -> Option<Ident> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct NameRef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for NameRef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for NameRef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
NAME_REF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl NameRef {
pub fn name_ref_token(&self) -> Option<NameRefToken> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MacroCall {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for MacroCall {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MacroCall {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MACRO_CALL => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::NameOwner for MacroCall {}
impl ast::AttrsOwner for MacroCall {}
impl ast::DocCommentsOwner for MacroCall {}
impl MacroCall {
2020-04-09 11:00:09 +00:00
pub fn path(&self) -> Option<Path> {
support::child(&self.syntax)
}
pub fn excl(&self) -> Option<Excl> {
support::token(&self.syntax)
}
pub fn token_tree(&self) -> Option<TokenTree> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
2020-04-09 11:00:09 +00:00
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
}
}
2019-08-23 12:55:21 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Attr {
2019-08-23 12:55:21 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Attr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Attr {
2019-08-23 12:55:21 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ATTR => true,
2019-08-23 12:55:21 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl Attr {
2020-04-09 11:00:09 +00:00
pub fn pound(&self) -> Option<Pound> {
support::token(&self.syntax)
}
pub fn excl(&self) -> Option<Excl> {
support::token(&self.syntax)
}
pub fn l_brack(&self) -> Option<LBrack> {
support::token(&self.syntax)
}
pub fn path(&self) -> Option<Path> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
2019-08-23 12:55:21 +00:00
}
pub fn input(&self) -> Option<AttrInput> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn r_brack(&self) -> Option<RBrack> {
support::token(&self.syntax)
2019-08-23 12:55:21 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TokenTree {
2019-08-23 12:55:21 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TokenTree {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TokenTree {
2019-08-23 12:55:21 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TOKEN_TREE => true,
2019-08-23 12:55:21 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl TokenTree {}
2019-08-23 12:55:21 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeParamList {
2019-08-23 12:55:21 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TypeParamList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TypeParamList {
2019-08-23 12:55:21 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TYPE_PARAM_LIST => true,
2019-08-23 12:55:21 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl TypeParamList {
2020-04-09 11:00:09 +00:00
pub fn l_angle(&self) -> Option<LAngle> {
support::token(&self.syntax)
}
pub fn generic_params(&self) -> AstChildren<GenericParam> {
support::children(&self.syntax)
}
pub fn type_params(&self) -> AstChildren<TypeParam> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
2019-08-23 12:55:21 +00:00
}
pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn const_params(&self) -> AstChildren<ConstParam> {
support::children(&self.syntax)
}
pub fn r_angle(&self) -> Option<RAngle> {
support::token(&self.syntax)
2019-08-23 12:55:21 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeParam {
2019-08-23 12:55:21 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TypeParam {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TypeParam {
2019-08-23 12:55:21 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TYPE_PARAM => true,
2019-08-23 12:55:21 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::NameOwner for TypeParam {}
impl ast::AttrsOwner for TypeParam {}
impl ast::TypeBoundsOwner for TypeParam {}
impl TypeParam {
2020-04-09 11:00:09 +00:00
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn default_type(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-08-23 12:55:21 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ConstParam {
2019-08-23 12:55:21 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ConstParam {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ConstParam {
2019-08-23 12:55:21 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CONST_PARAM => true,
2019-08-23 12:55:21 +00:00
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::NameOwner for ConstParam {}
impl ast::AttrsOwner for ConstParam {}
impl ast::TypeAscriptionOwner for ConstParam {}
impl ConstParam {
2020-04-09 11:00:09 +00:00
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn default_val(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-08-23 12:55:21 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LifetimeParam {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for LifetimeParam {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for LifetimeParam {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LIFETIME_PARAM => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::AttrsOwner for LifetimeParam {}
2020-04-09 11:00:09 +00:00
impl LifetimeParam {
pub fn lifetime(&self) -> Option<Lifetime> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeBound {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TypeBound {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TypeBound {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TYPE_BOUND => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl TypeBound {
2020-04-09 11:00:09 +00:00
pub fn lifetime(&self) -> Option<Lifetime> {
support::token(&self.syntax)
}
pub fn const_kw(&self) -> Option<ConstKw> {
support::token(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-01-13 10:34:57 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeBoundList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TypeBoundList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TypeBoundList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TYPE_BOUND_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl TypeBoundList {
pub fn bounds(&self) -> AstChildren<TypeBound> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct WherePred {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for WherePred {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for WherePred {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
WHERE_PRED => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-28 18:11:17 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::TypeBoundsOwner for WherePred {}
impl WherePred {
2020-04-09 11:00:09 +00:00
pub fn lifetime(&self) -> Option<Lifetime> {
support::token(&self.syntax)
}
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct WhereClause {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for WhereClause {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for WhereClause {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
WHERE_CLAUSE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl WhereClause {
2020-04-09 11:00:09 +00:00
pub fn where_kw(&self) -> Option<WhereKw> {
support::token(&self.syntax)
}
pub fn predicates(&self) -> AstChildren<WherePred> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Abi {
pub(crate) syntax: SyntaxNode,
}
impl std::fmt::Display for Abi {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Abi {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ABI => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl Abi {
pub fn string(&self) -> Option<String> {
support::token(&self.syntax)
2018-12-20 20:56:28 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ExprStmt {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ExprStmt {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ExprStmt {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
EXPR_STMT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-31 13:30:42 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for ExprStmt {}
impl ExprStmt {
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn semi(&self) -> Option<Semi> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LetStmt {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for LetStmt {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for LetStmt {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LET_STMT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for LetStmt {}
impl ast::TypeAscriptionOwner for LetStmt {}
impl LetStmt {
2020-04-09 11:00:09 +00:00
pub fn let_kw(&self) -> Option<LetKw> {
support::token(&self.syntax)
}
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn initializer(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Condition {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Condition {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Condition {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CONDITION => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-14 09:38:20 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl Condition {
2020-04-09 11:00:09 +00:00
pub fn let_kw(&self) -> Option<LetKw> {
support::token(&self.syntax)
}
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Block {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-07 15:38:43 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Block {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Block {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
BLOCK => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-11-07 15:38:43 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::AttrsOwner for Block {}
impl ast::ModuleItemOwner for Block {}
impl Block {
2020-04-09 11:00:09 +00:00
pub fn l_curly(&self) -> Option<LCurly> {
support::token(&self.syntax)
}
pub fn statements(&self) -> AstChildren<Stmt> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
2018-11-07 15:38:43 +00:00
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn r_curly(&self) -> Option<RCurly> {
support::token(&self.syntax)
}
2018-11-07 15:38:43 +00:00
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ParamList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ParamList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ParamList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PARAM_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-11 08:03:22 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ParamList {
2020-04-09 11:00:09 +00:00
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
pub fn self_param(&self) -> Option<SelfParam> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn params(&self) -> AstChildren<Param> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SelfParam {
pub(crate) syntax: SyntaxNode,
2019-02-24 13:57:05 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for SelfParam {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for SelfParam {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
SELF_PARAM => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2018-08-27 07:12:28 +00:00
}
}
impl ast::TypeAscriptionOwner for SelfParam {}
impl ast::AttrsOwner for SelfParam {}
2020-04-09 11:00:09 +00:00
impl SelfParam {
pub fn amp(&self) -> Option<Amp> {
support::token(&self.syntax)
}
pub fn lifetime(&self) -> Option<Lifetime> {
support::token(&self.syntax)
}
pub fn self_kw(&self) -> Option<SelfKw> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Param {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Param {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Param {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PARAM => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-11 07:56:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::TypeAscriptionOwner for Param {}
impl ast::AttrsOwner for Param {}
impl Param {
pub fn pat(&self) -> Option<Pat> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn dotdotdot(&self) -> Option<Dotdotdot> {
support::token(&self.syntax)
2019-07-19 15:22:00 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UseItem {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for UseItem {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for UseItem {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
USE_ITEM => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::AttrsOwner for UseItem {}
impl ast::VisibilityOwner for UseItem {}
impl UseItem {
2020-04-09 11:00:09 +00:00
pub fn use_kw(&self) -> Option<UseKw> {
support::token(&self.syntax)
}
pub fn use_tree(&self) -> Option<UseTree> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UseTree {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-16 09:51:40 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for UseTree {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for UseTree {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
USE_TREE => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-16 09:51:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl UseTree {
pub fn path(&self) -> Option<Path> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn star(&self) -> Option<Star> {
support::token(&self.syntax)
}
pub fn use_tree_list(&self) -> Option<UseTreeList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn alias(&self) -> Option<Alias> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-09-02 16:45:41 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Alias {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-11 08:03:22 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Alias {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Alias {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ALIAS => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-11 08:03:22 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::NameOwner for Alias {}
2020-04-09 11:00:09 +00:00
impl Alias {
pub fn as_kw(&self) -> Option<AsKw> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UseTreeList {
2019-06-06 11:36:16 +00:00
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for UseTreeList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for UseTreeList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
USE_TREE_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2019-06-06 11:36:16 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
2019-06-06 11:36:16 +00:00
}
impl UseTreeList {
2020-04-09 11:00:09 +00:00
pub fn l_curly(&self) -> Option<LCurly> {
support::token(&self.syntax)
}
pub fn use_trees(&self) -> AstChildren<UseTree> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_curly(&self) -> Option<RCurly> {
support::token(&self.syntax)
2019-08-23 12:55:21 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ExternCrateItem {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ExternCrateItem {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ExternCrateItem {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
EXTERN_CRATE_ITEM => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::AttrsOwner for ExternCrateItem {}
impl ast::VisibilityOwner for ExternCrateItem {}
impl ExternCrateItem {
2020-04-09 11:00:09 +00:00
pub fn extern_kw(&self) -> Option<ExternKw> {
support::token(&self.syntax)
}
pub fn crate_kw(&self) -> Option<CrateKw> {
support::token(&self.syntax)
}
pub fn name_ref(&self) -> Option<NameRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn alias(&self) -> Option<Alias> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-12-20 20:56:28 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ArgList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ArgList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ArgList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ARG_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ArgList {
2020-04-09 11:00:09 +00:00
pub fn l_paren(&self) -> Option<LParen> {
support::token(&self.syntax)
}
pub fn args(&self) -> AstChildren<Expr> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn r_paren(&self) -> Option<RParen> {
support::token(&self.syntax)
2019-01-13 11:52:25 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Path {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Path {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Path {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PATH => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl Path {
pub fn segment(&self) -> Option<PathSegment> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn qualifier(&self) -> Option<Path> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-01-15 14:24:04 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PathSegment {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for PathSegment {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for PathSegment {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PATH_SEGMENT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-26 09:09:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl PathSegment {
2020-04-09 11:00:09 +00:00
pub fn coloncolon(&self) -> Option<Coloncolon> {
support::token(&self.syntax)
}
pub fn l_angle(&self) -> Option<LAngle> {
support::token(&self.syntax)
}
pub fn name_ref(&self) -> Option<NameRef> {
support::child(&self.syntax)
}
pub fn type_arg_list(&self) -> Option<TypeArgList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2018-08-14 09:38:20 +00:00
}
pub fn param_list(&self) -> Option<ParamList> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-08-18 20:36:22 +00:00
}
pub fn ret_type(&self) -> Option<RetType> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
2019-07-19 15:22:00 +00:00
}
pub fn path_type(&self) -> Option<PathType> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn r_angle(&self) -> Option<RAngle> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeArgList {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TypeArgList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TypeArgList {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TYPE_ARG_LIST => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl TypeArgList {
2020-04-09 11:00:09 +00:00
pub fn coloncolon(&self) -> Option<Coloncolon> {
support::token(&self.syntax)
}
pub fn l_angle(&self) -> Option<LAngle> {
support::token(&self.syntax)
}
pub fn generic_args(&self) -> AstChildren<GenericArg> {
support::children(&self.syntax)
}
pub fn type_args(&self) -> AstChildren<TypeArg> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn const_args(&self) -> AstChildren<ConstArg> {
support::children(&self.syntax)
}
2020-04-09 11:00:09 +00:00
pub fn r_angle(&self) -> Option<RAngle> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeArg {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TypeArg {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TypeArg {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TYPE_ARG => true,
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl TypeArg {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AssocTypeArg {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for AssocTypeArg {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for AssocTypeArg {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
ASSOC_TYPE_ARG => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::TypeBoundsOwner for AssocTypeArg {}
impl AssocTypeArg {
pub fn name_ref(&self) -> Option<NameRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn type_ref(&self) -> Option<TypeRef> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LifetimeArg {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for LifetimeArg {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for LifetimeArg {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LIFETIME_ARG => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl LifetimeArg {
pub fn lifetime(&self) -> Option<Lifetime> {
support::token(&self.syntax)
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ConstArg {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ConstArg {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ConstArg {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
CONST_ARG => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ConstArg {
pub fn literal(&self) -> Option<Literal> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn block_expr(&self) -> Option<BlockExpr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MacroItems {
pub(crate) syntax: SyntaxNode,
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for MacroItems {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MacroItems {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MACRO_ITEMS => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl ast::ModuleItemOwner for MacroItems {}
impl ast::FnDefOwner for MacroItems {}
impl MacroItems {}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MacroStmts {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for MacroStmts {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MacroStmts {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MACRO_STMTS => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-22 16:02:37 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-08-18 20:36:22 +00:00
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
2019-07-19 15:22:00 +00:00
}
}
impl MacroStmts {
pub fn statements(&self) -> AstChildren<Stmt> {
2020-04-09 11:00:09 +00:00
support::children(&self.syntax)
}
pub fn expr(&self) -> Option<Expr> {
2020-04-09 11:00:09 +00:00
support::child(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ExternItemList {
pub(crate) syntax: SyntaxNode,
}
impl std::fmt::Display for ExternItemList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ExternItemList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
EXTERN_ITEM_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ast::FnDefOwner for ExternItemList {}
impl ast::ModuleItemOwner for ExternItemList {}
impl ExternItemList {
pub fn l_curly(&self) -> Option<LCurly> {
support::token(&self.syntax)
}
pub fn extern_items(&self) -> AstChildren<ExternItem> {
support::children(&self.syntax)
}
pub fn r_curly(&self) -> Option<RCurly> {
support::token(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ExternBlock {
pub(crate) syntax: SyntaxNode,
}
impl std::fmt::Display for ExternBlock {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ExternBlock {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
EXTERN_BLOCK => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl ExternBlock {
pub fn abi(&self) -> Option<Abi> {
support::child(&self.syntax)
}
pub fn extern_item_list(&self) -> Option<ExternItemList> {
support::child(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MetaItem {
pub(crate) syntax: SyntaxNode,
}
impl std::fmt::Display for MetaItem {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MetaItem {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
META_ITEM => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl MetaItem {
pub fn path(&self) -> Option<Path> {
support::child(&self.syntax)
}
pub fn eq(&self) -> Option<Eq> {
support::token(&self.syntax)
}
pub fn attr_input(&self) -> Option<AttrInput> {
support::child(&self.syntax)
}
pub fn nested_meta_items(&self) -> AstChildren<MetaItem> {
support::children(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MacroDef {
pub(crate) syntax: SyntaxNode,
}
impl std::fmt::Display for MacroDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for MacroDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MACRO_DEF => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxNode {
&self.syntax
}
}
impl MacroDef {
pub fn name(&self) -> Option<Name> {
support::child(&self.syntax)
}
pub fn token_tree(&self) -> Option<TokenTree> {
support::child(&self.syntax)
2019-11-20 08:42:58 +00:00
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum NominalDef {
StructDef(StructDef),
EnumDef(EnumDef),
UnionDef(UnionDef),
2018-11-06 19:47:38 +00:00
}
impl From<StructDef> for NominalDef {
fn from(node: StructDef) -> NominalDef {
NominalDef::StructDef(node)
}
}
impl From<EnumDef> for NominalDef {
fn from(node: EnumDef) -> NominalDef {
NominalDef::EnumDef(node)
}
}
impl From<UnionDef> for NominalDef {
fn from(node: UnionDef) -> NominalDef {
NominalDef::UnionDef(node)
}
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for NominalDef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for NominalDef {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-22 13:46:42 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
_ => return None,
};
Some(res)
2019-08-18 20:36:22 +00:00
}
fn syntax(&self) -> &SyntaxNode {
match self {
NominalDef::StructDef(it) => &it.syntax,
NominalDef::EnumDef(it) => &it.syntax,
NominalDef::UnionDef(it) => &it.syntax,
}
2018-08-28 20:59:57 +00:00
}
2018-08-22 16:02:37 +00:00
}
impl ast::NameOwner for NominalDef {}
impl ast::TypeParamsOwner for NominalDef {}
impl ast::AttrsOwner for NominalDef {}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2020-04-09 11:00:09 +00:00
pub enum GenericParam {
LifetimeParam(LifetimeParam),
TypeParam(TypeParam),
ConstParam(ConstParam),
}
impl From<LifetimeParam> for GenericParam {
fn from(node: LifetimeParam) -> GenericParam {
GenericParam::LifetimeParam(node)
}
}
impl From<TypeParam> for GenericParam {
fn from(node: TypeParam) -> GenericParam {
GenericParam::TypeParam(node)
}
}
impl From<ConstParam> for GenericParam {
fn from(node: ConstParam) -> GenericParam {
GenericParam::ConstParam(node)
}
}
impl std::fmt::Display for GenericParam {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for GenericParam {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }),
TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }),
CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxNode {
match self {
GenericParam::LifetimeParam(it) => &it.syntax,
GenericParam::TypeParam(it) => &it.syntax,
GenericParam::ConstParam(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum GenericArg {
LifetimeArg(LifetimeArg),
TypeArg(TypeArg),
ConstArg(ConstArg),
AssocTypeArg(AssocTypeArg),
}
impl From<LifetimeArg> for GenericArg {
fn from(node: LifetimeArg) -> GenericArg {
GenericArg::LifetimeArg(node)
}
}
impl From<TypeArg> for GenericArg {
fn from(node: TypeArg) -> GenericArg {
GenericArg::TypeArg(node)
}
}
impl From<ConstArg> for GenericArg {
fn from(node: ConstArg) -> GenericArg {
GenericArg::ConstArg(node)
}
}
impl From<AssocTypeArg> for GenericArg {
fn from(node: AssocTypeArg) -> GenericArg {
GenericArg::AssocTypeArg(node)
}
}
impl std::fmt::Display for GenericArg {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for GenericArg {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }),
TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }),
CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }),
ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxNode {
match self {
GenericArg::LifetimeArg(it) => &it.syntax,
GenericArg::TypeArg(it) => &it.syntax,
GenericArg::ConstArg(it) => &it.syntax,
GenericArg::AssocTypeArg(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TypeRef {
2019-07-18 16:23:05 +00:00
ParenType(ParenType),
TupleType(TupleType),
NeverType(NeverType),
PathType(PathType),
PointerType(PointerType),
ArrayType(ArrayType),
SliceType(SliceType),
ReferenceType(ReferenceType),
PlaceholderType(PlaceholderType),
FnPointerType(FnPointerType),
ForType(ForType),
ImplTraitType(ImplTraitType),
DynTraitType(DynTraitType),
2019-01-07 13:16:02 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<ParenType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: ParenType) -> TypeRef {
TypeRef::ParenType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<TupleType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: TupleType) -> TypeRef {
TypeRef::TupleType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<NeverType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: NeverType) -> TypeRef {
TypeRef::NeverType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<PathType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: PathType) -> TypeRef {
TypeRef::PathType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<PointerType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: PointerType) -> TypeRef {
TypeRef::PointerType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<ArrayType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: ArrayType) -> TypeRef {
TypeRef::ArrayType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<SliceType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: SliceType) -> TypeRef {
TypeRef::SliceType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<ReferenceType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: ReferenceType) -> TypeRef {
TypeRef::ReferenceType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<PlaceholderType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: PlaceholderType) -> TypeRef {
TypeRef::PlaceholderType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<FnPointerType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: FnPointerType) -> TypeRef {
TypeRef::FnPointerType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<ForType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: ForType) -> TypeRef {
TypeRef::ForType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<ImplTraitType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: ImplTraitType) -> TypeRef {
TypeRef::ImplTraitType(node)
2019-08-18 20:36:22 +00:00
}
2019-02-24 13:57:05 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<DynTraitType> for TypeRef {
2019-08-18 20:36:22 +00:00
fn from(node: DynTraitType) -> TypeRef {
TypeRef::DynTraitType(node)
}
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for TypeRef {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for TypeRef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
| SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
| IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
PATH_TYPE => TypeRef::PathType(PathType { syntax }),
POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
FOR_TYPE => TypeRef::ForType(ForType { syntax }),
IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxNode {
match self {
TypeRef::ParenType(it) => &it.syntax,
TypeRef::TupleType(it) => &it.syntax,
TypeRef::NeverType(it) => &it.syntax,
TypeRef::PathType(it) => &it.syntax,
TypeRef::PointerType(it) => &it.syntax,
TypeRef::ArrayType(it) => &it.syntax,
TypeRef::SliceType(it) => &it.syntax,
TypeRef::ReferenceType(it) => &it.syntax,
TypeRef::PlaceholderType(it) => &it.syntax,
TypeRef::FnPointerType(it) => &it.syntax,
TypeRef::ForType(it) => &it.syntax,
TypeRef::ImplTraitType(it) => &it.syntax,
TypeRef::DynTraitType(it) => &it.syntax,
2019-01-07 13:16:02 +00:00
}
}
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ModuleItem {
StructDef(StructDef),
UnionDef(UnionDef),
EnumDef(EnumDef),
FnDef(FnDef),
TraitDef(TraitDef),
TypeAliasDef(TypeAliasDef),
2020-02-29 20:24:40 +00:00
ImplDef(ImplDef),
UseItem(UseItem),
ExternCrateItem(ExternCrateItem),
ConstDef(ConstDef),
StaticDef(StaticDef),
Module(Module),
2020-03-26 15:10:01 +00:00
MacroCall(MacroCall),
2020-04-09 11:00:09 +00:00
ExternBlock(ExternBlock),
}
impl From<StructDef> for ModuleItem {
fn from(node: StructDef) -> ModuleItem {
ModuleItem::StructDef(node)
}
}
impl From<UnionDef> for ModuleItem {
fn from(node: UnionDef) -> ModuleItem {
ModuleItem::UnionDef(node)
}
}
impl From<EnumDef> for ModuleItem {
fn from(node: EnumDef) -> ModuleItem {
ModuleItem::EnumDef(node)
}
}
impl From<FnDef> for ModuleItem {
fn from(node: FnDef) -> ModuleItem {
ModuleItem::FnDef(node)
2019-11-25 14:30:50 +00:00
}
}
impl From<TraitDef> for ModuleItem {
fn from(node: TraitDef) -> ModuleItem {
ModuleItem::TraitDef(node)
}
2018-08-28 08:12:42 +00:00
}
impl From<TypeAliasDef> for ModuleItem {
fn from(node: TypeAliasDef) -> ModuleItem {
ModuleItem::TypeAliasDef(node)
2018-08-28 08:12:42 +00:00
}
}
2020-02-29 20:24:40 +00:00
impl From<ImplDef> for ModuleItem {
fn from(node: ImplDef) -> ModuleItem {
ModuleItem::ImplDef(node)
2019-08-18 20:36:22 +00:00
}
}
impl From<UseItem> for ModuleItem {
fn from(node: UseItem) -> ModuleItem {
ModuleItem::UseItem(node)
2019-07-19 15:22:00 +00:00
}
}
impl From<ExternCrateItem> for ModuleItem {
fn from(node: ExternCrateItem) -> ModuleItem {
ModuleItem::ExternCrateItem(node)
}
}
impl From<ConstDef> for ModuleItem {
fn from(node: ConstDef) -> ModuleItem {
ModuleItem::ConstDef(node)
}
2018-08-30 17:37:33 +00:00
}
impl From<StaticDef> for ModuleItem {
fn from(node: StaticDef) -> ModuleItem {
ModuleItem::StaticDef(node)
}
}
impl From<Module> for ModuleItem {
fn from(node: Module) -> ModuleItem {
ModuleItem::Module(node)
}
}
2020-03-26 15:10:01 +00:00
impl From<MacroCall> for ModuleItem {
fn from(node: MacroCall) -> ModuleItem {
ModuleItem::MacroCall(node)
}
}
2020-04-09 11:00:09 +00:00
impl From<ExternBlock> for ModuleItem {
fn from(node: ExternBlock) -> ModuleItem {
ModuleItem::ExternBlock(node)
}
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ModuleItem {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ModuleItem {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
2020-02-29 20:24:40 +00:00
STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF
2020-04-09 11:00:09 +00:00
| USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL
| EXTERN_BLOCK => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-30 17:37:33 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
2020-02-29 20:24:40 +00:00
IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }),
USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
MODULE => ModuleItem::Module(Module { syntax }),
2020-03-26 15:10:01 +00:00
MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }),
2020-04-09 11:00:09 +00:00
EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }),
_ => return None,
};
Some(res)
2019-08-18 20:36:22 +00:00
}
fn syntax(&self) -> &SyntaxNode {
match self {
ModuleItem::StructDef(it) => &it.syntax,
ModuleItem::UnionDef(it) => &it.syntax,
ModuleItem::EnumDef(it) => &it.syntax,
ModuleItem::FnDef(it) => &it.syntax,
ModuleItem::TraitDef(it) => &it.syntax,
ModuleItem::TypeAliasDef(it) => &it.syntax,
2020-02-29 20:24:40 +00:00
ModuleItem::ImplDef(it) => &it.syntax,
ModuleItem::UseItem(it) => &it.syntax,
ModuleItem::ExternCrateItem(it) => &it.syntax,
ModuleItem::ConstDef(it) => &it.syntax,
ModuleItem::StaticDef(it) => &it.syntax,
ModuleItem::Module(it) => &it.syntax,
2020-03-26 15:10:01 +00:00
ModuleItem::MacroCall(it) => &it.syntax,
2020-04-09 11:00:09 +00:00
ModuleItem::ExternBlock(it) => &it.syntax,
}
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::NameOwner for ModuleItem {}
impl ast::AttrsOwner for ModuleItem {}
impl ast::VisibilityOwner for ModuleItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ImplItem {
FnDef(FnDef),
TypeAliasDef(TypeAliasDef),
ConstDef(ConstDef),
}
impl From<FnDef> for ImplItem {
fn from(node: FnDef) -> ImplItem {
ImplItem::FnDef(node)
2018-08-30 17:37:33 +00:00
}
}
impl From<TypeAliasDef> for ImplItem {
fn from(node: TypeAliasDef) -> ImplItem {
ImplItem::TypeAliasDef(node)
2019-02-01 23:18:10 +00:00
}
2018-08-30 17:37:33 +00:00
}
impl From<ConstDef> for ImplItem {
fn from(node: ConstDef) -> ImplItem {
ImplItem::ConstDef(node)
}
2018-11-06 19:47:38 +00:00
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for ImplItem {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ImplItem {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-30 17:37:33 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
FN_DEF => ImplItem::FnDef(FnDef { syntax }),
TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }),
CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxNode {
match self {
ImplItem::FnDef(it) => &it.syntax,
ImplItem::TypeAliasDef(it) => &it.syntax,
ImplItem::ConstDef(it) => &it.syntax,
}
}
}
2020-04-09 11:00:09 +00:00
impl ast::NameOwner for ImplItem {}
impl ast::AttrsOwner for ImplItem {}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2020-04-09 11:00:09 +00:00
pub enum ExternItem {
FnDef(FnDef),
StaticDef(StaticDef),
}
impl From<FnDef> for ExternItem {
fn from(node: FnDef) -> ExternItem {
ExternItem::FnDef(node)
}
}
impl From<StaticDef> for ExternItem {
fn from(node: StaticDef) -> ExternItem {
ExternItem::StaticDef(node)
}
}
impl std::fmt::Display for ExternItem {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for ExternItem {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
FN_DEF | STATIC_DEF => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
FN_DEF => ExternItem::FnDef(FnDef { syntax }),
STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxNode {
match self {
ExternItem::FnDef(it) => &it.syntax,
ExternItem::StaticDef(it) => &it.syntax,
}
}
}
impl ast::NameOwner for ExternItem {}
impl ast::AttrsOwner for ExternItem {}
impl ast::VisibilityOwner for ExternItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Expr {
TupleExpr(TupleExpr),
ArrayExpr(ArrayExpr),
ParenExpr(ParenExpr),
PathExpr(PathExpr),
LambdaExpr(LambdaExpr),
IfExpr(IfExpr),
LoopExpr(LoopExpr),
ForExpr(ForExpr),
WhileExpr(WhileExpr),
ContinueExpr(ContinueExpr),
BreakExpr(BreakExpr),
Label(Label),
BlockExpr(BlockExpr),
ReturnExpr(ReturnExpr),
MatchExpr(MatchExpr),
RecordLit(RecordLit),
CallExpr(CallExpr),
IndexExpr(IndexExpr),
MethodCallExpr(MethodCallExpr),
FieldExpr(FieldExpr),
AwaitExpr(AwaitExpr),
TryExpr(TryExpr),
TryBlockExpr(TryBlockExpr),
CastExpr(CastExpr),
RefExpr(RefExpr),
PrefixExpr(PrefixExpr),
RangeExpr(RangeExpr),
BinExpr(BinExpr),
Literal(Literal),
MacroCall(MacroCall),
BoxExpr(BoxExpr),
2019-01-03 10:47:28 +00:00
}
impl From<TupleExpr> for Expr {
fn from(node: TupleExpr) -> Expr {
Expr::TupleExpr(node)
}
}
impl From<ArrayExpr> for Expr {
fn from(node: ArrayExpr) -> Expr {
Expr::ArrayExpr(node)
}
}
impl From<ParenExpr> for Expr {
fn from(node: ParenExpr) -> Expr {
Expr::ParenExpr(node)
}
}
impl From<PathExpr> for Expr {
fn from(node: PathExpr) -> Expr {
Expr::PathExpr(node)
}
}
impl From<LambdaExpr> for Expr {
fn from(node: LambdaExpr) -> Expr {
Expr::LambdaExpr(node)
}
}
impl From<IfExpr> for Expr {
fn from(node: IfExpr) -> Expr {
Expr::IfExpr(node)
}
}
impl From<LoopExpr> for Expr {
fn from(node: LoopExpr) -> Expr {
Expr::LoopExpr(node)
}
}
impl From<ForExpr> for Expr {
fn from(node: ForExpr) -> Expr {
Expr::ForExpr(node)
}
}
impl From<WhileExpr> for Expr {
fn from(node: WhileExpr) -> Expr {
Expr::WhileExpr(node)
}
}
impl From<ContinueExpr> for Expr {
fn from(node: ContinueExpr) -> Expr {
Expr::ContinueExpr(node)
}
}
impl From<BreakExpr> for Expr {
fn from(node: BreakExpr) -> Expr {
Expr::BreakExpr(node)
}
}
impl From<Label> for Expr {
fn from(node: Label) -> Expr {
Expr::Label(node)
}
}
impl From<BlockExpr> for Expr {
fn from(node: BlockExpr) -> Expr {
Expr::BlockExpr(node)
}
}
impl From<ReturnExpr> for Expr {
fn from(node: ReturnExpr) -> Expr {
Expr::ReturnExpr(node)
}
}
impl From<MatchExpr> for Expr {
fn from(node: MatchExpr) -> Expr {
Expr::MatchExpr(node)
}
}
impl From<RecordLit> for Expr {
fn from(node: RecordLit) -> Expr {
Expr::RecordLit(node)
}
}
impl From<CallExpr> for Expr {
fn from(node: CallExpr) -> Expr {
Expr::CallExpr(node)
}
}
impl From<IndexExpr> for Expr {
fn from(node: IndexExpr) -> Expr {
Expr::IndexExpr(node)
}
}
impl From<MethodCallExpr> for Expr {
fn from(node: MethodCallExpr) -> Expr {
Expr::MethodCallExpr(node)
}
}
impl From<FieldExpr> for Expr {
fn from(node: FieldExpr) -> Expr {
Expr::FieldExpr(node)
}
}
impl From<AwaitExpr> for Expr {
fn from(node: AwaitExpr) -> Expr {
Expr::AwaitExpr(node)
}
}
impl From<TryExpr> for Expr {
fn from(node: TryExpr) -> Expr {
Expr::TryExpr(node)
}
}
impl From<TryBlockExpr> for Expr {
fn from(node: TryBlockExpr) -> Expr {
Expr::TryBlockExpr(node)
}
}
impl From<CastExpr> for Expr {
fn from(node: CastExpr) -> Expr {
Expr::CastExpr(node)
}
}
impl From<RefExpr> for Expr {
fn from(node: RefExpr) -> Expr {
Expr::RefExpr(node)
}
}
impl From<PrefixExpr> for Expr {
fn from(node: PrefixExpr) -> Expr {
Expr::PrefixExpr(node)
}
}
impl From<RangeExpr> for Expr {
fn from(node: RangeExpr) -> Expr {
Expr::RangeExpr(node)
}
}
impl From<BinExpr> for Expr {
fn from(node: BinExpr) -> Expr {
Expr::BinExpr(node)
}
}
impl From<Literal> for Expr {
fn from(node: Literal) -> Expr {
Expr::Literal(node)
}
}
impl From<MacroCall> for Expr {
fn from(node: MacroCall) -> Expr {
Expr::MacroCall(node)
}
}
impl From<BoxExpr> for Expr {
fn from(node: BoxExpr) -> Expr {
Expr::BoxExpr(node)
}
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Expr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Expr {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
| LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
| BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
| METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
| CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL
| BOX_EXPR => true,
2019-07-19 15:22:00 +00:00
_ => false,
2019-01-03 10:47:28 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }),
PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }),
PATH_EXPR => Expr::PathExpr(PathExpr { syntax }),
LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }),
IF_EXPR => Expr::IfExpr(IfExpr { syntax }),
LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }),
FOR_EXPR => Expr::ForExpr(ForExpr { syntax }),
WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }),
BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }),
LABEL => Expr::Label(Label { syntax }),
BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }),
AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }),
TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
TRY_BLOCK_EXPR => Expr::TryBlockExpr(TryBlockExpr { syntax }),
CAST_EXPR => Expr::CastExpr(CastExpr { syntax }),
REF_EXPR => Expr::RefExpr(RefExpr { syntax }),
PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }),
RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }),
BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
LITERAL => Expr::Literal(Literal { syntax }),
MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
_ => return None,
};
Some(res)
2019-08-18 20:36:22 +00:00
}
fn syntax(&self) -> &SyntaxNode {
match self {
Expr::TupleExpr(it) => &it.syntax,
Expr::ArrayExpr(it) => &it.syntax,
Expr::ParenExpr(it) => &it.syntax,
Expr::PathExpr(it) => &it.syntax,
Expr::LambdaExpr(it) => &it.syntax,
Expr::IfExpr(it) => &it.syntax,
Expr::LoopExpr(it) => &it.syntax,
Expr::ForExpr(it) => &it.syntax,
Expr::WhileExpr(it) => &it.syntax,
Expr::ContinueExpr(it) => &it.syntax,
Expr::BreakExpr(it) => &it.syntax,
Expr::Label(it) => &it.syntax,
Expr::BlockExpr(it) => &it.syntax,
Expr::ReturnExpr(it) => &it.syntax,
Expr::MatchExpr(it) => &it.syntax,
Expr::RecordLit(it) => &it.syntax,
Expr::CallExpr(it) => &it.syntax,
Expr::IndexExpr(it) => &it.syntax,
Expr::MethodCallExpr(it) => &it.syntax,
Expr::FieldExpr(it) => &it.syntax,
Expr::AwaitExpr(it) => &it.syntax,
Expr::TryExpr(it) => &it.syntax,
Expr::TryBlockExpr(it) => &it.syntax,
Expr::CastExpr(it) => &it.syntax,
Expr::RefExpr(it) => &it.syntax,
Expr::PrefixExpr(it) => &it.syntax,
Expr::RangeExpr(it) => &it.syntax,
Expr::BinExpr(it) => &it.syntax,
Expr::Literal(it) => &it.syntax,
Expr::MacroCall(it) => &it.syntax,
Expr::BoxExpr(it) => &it.syntax,
}
2019-07-19 15:22:00 +00:00
}
}
2020-04-09 11:00:09 +00:00
impl ast::AttrsOwner for Expr {}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Pat {
2020-02-09 18:57:01 +00:00
OrPat(OrPat),
ParenPat(ParenPat),
RefPat(RefPat),
BoxPat(BoxPat),
BindPat(BindPat),
PlaceholderPat(PlaceholderPat),
DotDotPat(DotDotPat),
PathPat(PathPat),
RecordPat(RecordPat),
TupleStructPat(TupleStructPat),
TuplePat(TuplePat),
SlicePat(SlicePat),
RangePat(RangePat),
LiteralPat(LiteralPat),
MacroPat(MacroPat),
2018-11-06 19:47:38 +00:00
}
2020-02-09 18:57:01 +00:00
impl From<OrPat> for Pat {
fn from(node: OrPat) -> Pat {
Pat::OrPat(node)
}
}
impl From<ParenPat> for Pat {
fn from(node: ParenPat) -> Pat {
Pat::ParenPat(node)
}
}
impl From<RefPat> for Pat {
fn from(node: RefPat) -> Pat {
Pat::RefPat(node)
}
}
impl From<BoxPat> for Pat {
fn from(node: BoxPat) -> Pat {
Pat::BoxPat(node)
}
}
impl From<BindPat> for Pat {
fn from(node: BindPat) -> Pat {
Pat::BindPat(node)
}
}
impl From<PlaceholderPat> for Pat {
fn from(node: PlaceholderPat) -> Pat {
Pat::PlaceholderPat(node)
}
}
impl From<DotDotPat> for Pat {
fn from(node: DotDotPat) -> Pat {
Pat::DotDotPat(node)
}
}
impl From<PathPat> for Pat {
fn from(node: PathPat) -> Pat {
Pat::PathPat(node)
}
}
impl From<RecordPat> for Pat {
fn from(node: RecordPat) -> Pat {
Pat::RecordPat(node)
}
}
impl From<TupleStructPat> for Pat {
fn from(node: TupleStructPat) -> Pat {
Pat::TupleStructPat(node)
}
}
impl From<TuplePat> for Pat {
fn from(node: TuplePat) -> Pat {
Pat::TuplePat(node)
}
}
impl From<SlicePat> for Pat {
fn from(node: SlicePat) -> Pat {
Pat::SlicePat(node)
}
}
impl From<RangePat> for Pat {
fn from(node: RangePat) -> Pat {
Pat::RangePat(node)
}
}
impl From<LiteralPat> for Pat {
fn from(node: LiteralPat) -> Pat {
Pat::LiteralPat(node)
}
}
impl From<MacroPat> for Pat {
fn from(node: MacroPat) -> Pat {
Pat::MacroPat(node)
}
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Pat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Pat {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
2020-02-09 18:57:01 +00:00
OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT
| PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT
| LITERAL_PAT | MACRO_PAT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-22 08:56:36 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
2020-02-09 18:57:01 +00:00
OR_PAT => Pat::OrPat(OrPat { syntax }),
PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
REF_PAT => Pat::RefPat(RefPat { syntax }),
BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
BIND_PAT => Pat::BindPat(BindPat { syntax }),
PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
PATH_PAT => Pat::PathPat(PathPat { syntax }),
RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
RANGE_PAT => Pat::RangePat(RangePat { syntax }),
LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
MACRO_PAT => Pat::MacroPat(MacroPat { syntax }),
_ => return None,
};
Some(res)
2019-08-18 20:36:22 +00:00
}
fn syntax(&self) -> &SyntaxNode {
match self {
2020-02-09 18:57:01 +00:00
Pat::OrPat(it) => &it.syntax,
Pat::ParenPat(it) => &it.syntax,
Pat::RefPat(it) => &it.syntax,
Pat::BoxPat(it) => &it.syntax,
Pat::BindPat(it) => &it.syntax,
Pat::PlaceholderPat(it) => &it.syntax,
Pat::DotDotPat(it) => &it.syntax,
Pat::PathPat(it) => &it.syntax,
Pat::RecordPat(it) => &it.syntax,
Pat::TupleStructPat(it) => &it.syntax,
Pat::TuplePat(it) => &it.syntax,
Pat::SlicePat(it) => &it.syntax,
Pat::RangePat(it) => &it.syntax,
Pat::LiteralPat(it) => &it.syntax,
Pat::MacroPat(it) => &it.syntax,
}
2019-07-19 15:22:00 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2020-04-09 11:00:09 +00:00
pub enum RecordInnerPat {
RecordFieldPat(RecordFieldPat),
BindPat(BindPat),
}
impl From<RecordFieldPat> for RecordInnerPat {
fn from(node: RecordFieldPat) -> RecordInnerPat {
RecordInnerPat::RecordFieldPat(node)
}
}
impl From<BindPat> for RecordInnerPat {
fn from(node: BindPat) -> RecordInnerPat {
RecordInnerPat::BindPat(node)
}
}
impl std::fmt::Display for RecordInnerPat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for RecordInnerPat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_PAT | BIND_PAT => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
RECORD_FIELD_PAT => RecordInnerPat::RecordFieldPat(RecordFieldPat { syntax }),
BIND_PAT => RecordInnerPat::BindPat(BindPat { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxNode {
match self {
RecordInnerPat::RecordFieldPat(it) => &it.syntax,
RecordInnerPat::BindPat(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum AttrInput {
Literal(Literal),
TokenTree(TokenTree),
}
impl From<Literal> for AttrInput {
fn from(node: Literal) -> AttrInput {
AttrInput::Literal(node)
}
}
impl From<TokenTree> for AttrInput {
fn from(node: TokenTree) -> AttrInput {
AttrInput::TokenTree(node)
}
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for AttrInput {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for AttrInput {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
LITERAL | TOKEN_TREE => true,
2019-07-19 15:22:00 +00:00
_ => false,
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
LITERAL => AttrInput::Literal(Literal { syntax }),
TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
_ => return None,
};
Some(res)
2019-08-18 20:36:22 +00:00
}
fn syntax(&self) -> &SyntaxNode {
match self {
AttrInput::Literal(it) => &it.syntax,
AttrInput::TokenTree(it) => &it.syntax,
}
2019-07-19 15:22:00 +00:00
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Stmt {
LetStmt(LetStmt),
2020-04-09 11:00:09 +00:00
ExprStmt(ExprStmt),
}
impl From<LetStmt> for Stmt {
fn from(node: LetStmt) -> Stmt {
Stmt::LetStmt(node)
}
2018-11-06 19:47:38 +00:00
}
2020-04-09 11:00:09 +00:00
impl From<ExprStmt> for Stmt {
fn from(node: ExprStmt) -> Stmt {
Stmt::ExprStmt(node)
}
}
2020-03-11 20:54:24 +00:00
impl std::fmt::Display for Stmt {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for Stmt {
2019-07-19 15:22:00 +00:00
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
2020-04-09 11:00:09 +00:00
LET_STMT | EXPR_STMT => true,
2019-07-19 15:22:00 +00:00
_ => false,
2018-08-25 10:42:40 +00:00
}
}
2019-07-19 15:22:00 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
2020-04-09 11:00:09 +00:00
EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
_ => return None,
};
Some(res)
2019-08-18 20:36:22 +00:00
}
fn syntax(&self) -> &SyntaxNode {
match self {
Stmt::LetStmt(it) => &it.syntax,
2020-04-09 11:00:09 +00:00
Stmt::ExprStmt(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LeftDelimiter {
LParen(LParen),
LBrack(LBrack),
LCurly(LCurly),
}
impl From<LParen> for LeftDelimiter {
fn from(node: LParen) -> LeftDelimiter {
LeftDelimiter::LParen(node)
}
}
impl From<LBrack> for LeftDelimiter {
fn from(node: LBrack) -> LeftDelimiter {
LeftDelimiter::LBrack(node)
}
}
impl From<LCurly> for LeftDelimiter {
fn from(node: LCurly) -> LeftDelimiter {
LeftDelimiter::LCurly(node)
}
}
impl std::fmt::Display for LeftDelimiter {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstToken for LeftDelimiter {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
L_PAREN | L_BRACK | L_CURLY => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
let res = match syntax.kind() {
L_PAREN => LeftDelimiter::LParen(LParen { syntax }),
L_BRACK => LeftDelimiter::LBrack(LBrack { syntax }),
L_CURLY => LeftDelimiter::LCurly(LCurly { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxToken {
match self {
LeftDelimiter::LParen(it) => &it.syntax,
LeftDelimiter::LBrack(it) => &it.syntax,
LeftDelimiter::LCurly(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RightDelimiter {
RParen(RParen),
RBrack(RBrack),
RCurly(RCurly),
}
impl From<RParen> for RightDelimiter {
fn from(node: RParen) -> RightDelimiter {
RightDelimiter::RParen(node)
}
}
impl From<RBrack> for RightDelimiter {
fn from(node: RBrack) -> RightDelimiter {
RightDelimiter::RBrack(node)
}
}
impl From<RCurly> for RightDelimiter {
fn from(node: RCurly) -> RightDelimiter {
RightDelimiter::RCurly(node)
}
}
impl std::fmt::Display for RightDelimiter {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstToken for RightDelimiter {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
R_PAREN | R_BRACK | R_CURLY => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
let res = match syntax.kind() {
R_PAREN => RightDelimiter::RParen(RParen { syntax }),
R_BRACK => RightDelimiter::RBrack(RBrack { syntax }),
R_CURLY => RightDelimiter::RCurly(RCurly { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxToken {
match self {
RightDelimiter::RParen(it) => &it.syntax,
RightDelimiter::RBrack(it) => &it.syntax,
RightDelimiter::RCurly(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RangeSeparator {
Dotdot(Dotdot),
Dotdotdot(Dotdotdot),
Dotdoteq(Dotdoteq),
}
impl From<Dotdot> for RangeSeparator {
fn from(node: Dotdot) -> RangeSeparator {
RangeSeparator::Dotdot(node)
}
}
impl From<Dotdotdot> for RangeSeparator {
fn from(node: Dotdotdot) -> RangeSeparator {
RangeSeparator::Dotdotdot(node)
}
}
impl From<Dotdoteq> for RangeSeparator {
fn from(node: Dotdoteq) -> RangeSeparator {
RangeSeparator::Dotdoteq(node)
}
}
impl std::fmt::Display for RangeSeparator {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstToken for RangeSeparator {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DOTDOT | DOTDOTDOT | DOTDOTEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
let res = match syntax.kind() {
DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }),
DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }),
DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxToken {
match self {
RangeSeparator::Dotdot(it) => &it.syntax,
RangeSeparator::Dotdotdot(it) => &it.syntax,
RangeSeparator::Dotdoteq(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BinOp {
Pipepipe(Pipepipe),
Ampamp(Ampamp),
Eqeq(Eqeq),
Neq(Neq),
Lteq(Lteq),
Gteq(Gteq),
LAngle(LAngle),
RAngle(RAngle),
Plus(Plus),
Star(Star),
Minus(Minus),
Slash(Slash),
Percent(Percent),
Shl(Shl),
Shr(Shr),
Caret(Caret),
Pipe(Pipe),
Amp(Amp),
Eq(Eq),
Pluseq(Pluseq),
Slasheq(Slasheq),
Stareq(Stareq),
Percenteq(Percenteq),
Shreq(Shreq),
Shleq(Shleq),
Minuseq(Minuseq),
Pipeeq(Pipeeq),
Ampeq(Ampeq),
Careteq(Careteq),
}
impl From<Pipepipe> for BinOp {
fn from(node: Pipepipe) -> BinOp {
BinOp::Pipepipe(node)
}
}
impl From<Ampamp> for BinOp {
fn from(node: Ampamp) -> BinOp {
BinOp::Ampamp(node)
}
}
impl From<Eqeq> for BinOp {
fn from(node: Eqeq) -> BinOp {
BinOp::Eqeq(node)
}
}
impl From<Neq> for BinOp {
fn from(node: Neq) -> BinOp {
BinOp::Neq(node)
}
}
impl From<Lteq> for BinOp {
fn from(node: Lteq) -> BinOp {
BinOp::Lteq(node)
}
}
impl From<Gteq> for BinOp {
fn from(node: Gteq) -> BinOp {
BinOp::Gteq(node)
}
}
impl From<LAngle> for BinOp {
fn from(node: LAngle) -> BinOp {
BinOp::LAngle(node)
}
}
impl From<RAngle> for BinOp {
fn from(node: RAngle) -> BinOp {
BinOp::RAngle(node)
}
}
impl From<Plus> for BinOp {
fn from(node: Plus) -> BinOp {
BinOp::Plus(node)
}
}
impl From<Star> for BinOp {
fn from(node: Star) -> BinOp {
BinOp::Star(node)
}
}
impl From<Minus> for BinOp {
fn from(node: Minus) -> BinOp {
BinOp::Minus(node)
}
}
impl From<Slash> for BinOp {
fn from(node: Slash) -> BinOp {
BinOp::Slash(node)
}
}
impl From<Percent> for BinOp {
fn from(node: Percent) -> BinOp {
BinOp::Percent(node)
}
}
impl From<Shl> for BinOp {
fn from(node: Shl) -> BinOp {
BinOp::Shl(node)
}
}
impl From<Shr> for BinOp {
fn from(node: Shr) -> BinOp {
BinOp::Shr(node)
}
}
impl From<Caret> for BinOp {
fn from(node: Caret) -> BinOp {
BinOp::Caret(node)
}
}
impl From<Pipe> for BinOp {
fn from(node: Pipe) -> BinOp {
BinOp::Pipe(node)
}
}
impl From<Amp> for BinOp {
fn from(node: Amp) -> BinOp {
BinOp::Amp(node)
}
}
impl From<Eq> for BinOp {
fn from(node: Eq) -> BinOp {
BinOp::Eq(node)
}
}
impl From<Pluseq> for BinOp {
fn from(node: Pluseq) -> BinOp {
BinOp::Pluseq(node)
}
}
impl From<Slasheq> for BinOp {
fn from(node: Slasheq) -> BinOp {
BinOp::Slasheq(node)
}
}
impl From<Stareq> for BinOp {
fn from(node: Stareq) -> BinOp {
BinOp::Stareq(node)
}
}
impl From<Percenteq> for BinOp {
fn from(node: Percenteq) -> BinOp {
BinOp::Percenteq(node)
}
}
impl From<Shreq> for BinOp {
fn from(node: Shreq) -> BinOp {
BinOp::Shreq(node)
}
}
impl From<Shleq> for BinOp {
fn from(node: Shleq) -> BinOp {
BinOp::Shleq(node)
}
}
impl From<Minuseq> for BinOp {
fn from(node: Minuseq) -> BinOp {
BinOp::Minuseq(node)
}
}
impl From<Pipeeq> for BinOp {
fn from(node: Pipeeq) -> BinOp {
BinOp::Pipeeq(node)
}
}
impl From<Ampeq> for BinOp {
fn from(node: Ampeq) -> BinOp {
BinOp::Ampeq(node)
}
}
impl From<Careteq> for BinOp {
fn from(node: Careteq) -> BinOp {
BinOp::Careteq(node)
}
}
impl std::fmt::Display for BinOp {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstToken for BinOp {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR
| MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ
| STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
let res = match syntax.kind() {
PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }),
AMPAMP => BinOp::Ampamp(Ampamp { syntax }),
EQEQ => BinOp::Eqeq(Eqeq { syntax }),
NEQ => BinOp::Neq(Neq { syntax }),
LTEQ => BinOp::Lteq(Lteq { syntax }),
GTEQ => BinOp::Gteq(Gteq { syntax }),
L_ANGLE => BinOp::LAngle(LAngle { syntax }),
R_ANGLE => BinOp::RAngle(RAngle { syntax }),
PLUS => BinOp::Plus(Plus { syntax }),
STAR => BinOp::Star(Star { syntax }),
MINUS => BinOp::Minus(Minus { syntax }),
SLASH => BinOp::Slash(Slash { syntax }),
PERCENT => BinOp::Percent(Percent { syntax }),
SHL => BinOp::Shl(Shl { syntax }),
SHR => BinOp::Shr(Shr { syntax }),
CARET => BinOp::Caret(Caret { syntax }),
PIPE => BinOp::Pipe(Pipe { syntax }),
AMP => BinOp::Amp(Amp { syntax }),
EQ => BinOp::Eq(Eq { syntax }),
PLUSEQ => BinOp::Pluseq(Pluseq { syntax }),
SLASHEQ => BinOp::Slasheq(Slasheq { syntax }),
STAREQ => BinOp::Stareq(Stareq { syntax }),
PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }),
SHREQ => BinOp::Shreq(Shreq { syntax }),
SHLEQ => BinOp::Shleq(Shleq { syntax }),
MINUSEQ => BinOp::Minuseq(Minuseq { syntax }),
PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }),
AMPEQ => BinOp::Ampeq(Ampeq { syntax }),
CARETEQ => BinOp::Careteq(Careteq { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxToken {
match self {
BinOp::Pipepipe(it) => &it.syntax,
BinOp::Ampamp(it) => &it.syntax,
BinOp::Eqeq(it) => &it.syntax,
BinOp::Neq(it) => &it.syntax,
BinOp::Lteq(it) => &it.syntax,
BinOp::Gteq(it) => &it.syntax,
BinOp::LAngle(it) => &it.syntax,
BinOp::RAngle(it) => &it.syntax,
BinOp::Plus(it) => &it.syntax,
BinOp::Star(it) => &it.syntax,
BinOp::Minus(it) => &it.syntax,
BinOp::Slash(it) => &it.syntax,
BinOp::Percent(it) => &it.syntax,
BinOp::Shl(it) => &it.syntax,
BinOp::Shr(it) => &it.syntax,
BinOp::Caret(it) => &it.syntax,
BinOp::Pipe(it) => &it.syntax,
BinOp::Amp(it) => &it.syntax,
BinOp::Eq(it) => &it.syntax,
BinOp::Pluseq(it) => &it.syntax,
BinOp::Slasheq(it) => &it.syntax,
BinOp::Stareq(it) => &it.syntax,
BinOp::Percenteq(it) => &it.syntax,
BinOp::Shreq(it) => &it.syntax,
BinOp::Shleq(it) => &it.syntax,
BinOp::Minuseq(it) => &it.syntax,
BinOp::Pipeeq(it) => &it.syntax,
BinOp::Ampeq(it) => &it.syntax,
BinOp::Careteq(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum PrefixOp {
Minus(Minus),
Excl(Excl),
Star(Star),
}
impl From<Minus> for PrefixOp {
fn from(node: Minus) -> PrefixOp {
PrefixOp::Minus(node)
}
}
impl From<Excl> for PrefixOp {
fn from(node: Excl) -> PrefixOp {
PrefixOp::Excl(node)
}
}
impl From<Star> for PrefixOp {
fn from(node: Star) -> PrefixOp {
PrefixOp::Star(node)
}
}
impl std::fmt::Display for PrefixOp {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstToken for PrefixOp {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
MINUS | EXCL | STAR => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
let res = match syntax.kind() {
MINUS => PrefixOp::Minus(Minus { syntax }),
EXCL => PrefixOp::Excl(Excl { syntax }),
STAR => PrefixOp::Star(Star { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxToken {
match self {
PrefixOp::Minus(it) => &it.syntax,
PrefixOp::Excl(it) => &it.syntax,
PrefixOp::Star(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RangeOp {
Dotdot(Dotdot),
Dotdoteq(Dotdoteq),
}
impl From<Dotdot> for RangeOp {
fn from(node: Dotdot) -> RangeOp {
RangeOp::Dotdot(node)
}
}
impl From<Dotdoteq> for RangeOp {
fn from(node: Dotdoteq) -> RangeOp {
RangeOp::Dotdoteq(node)
}
}
impl std::fmt::Display for RangeOp {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstToken for RangeOp {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
DOTDOT | DOTDOTEQ => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
let res = match syntax.kind() {
DOTDOT => RangeOp::Dotdot(Dotdot { syntax }),
DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxToken {
match self {
RangeOp::Dotdot(it) => &it.syntax,
RangeOp::Dotdoteq(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LiteralToken {
IntNumber(IntNumber),
FloatNumber(FloatNumber),
String(String),
RawString(RawString),
TrueKw(TrueKw),
FalseKw(FalseKw),
ByteString(ByteString),
RawByteString(RawByteString),
Char(Char),
Byte(Byte),
}
impl From<IntNumber> for LiteralToken {
fn from(node: IntNumber) -> LiteralToken {
LiteralToken::IntNumber(node)
}
}
impl From<FloatNumber> for LiteralToken {
fn from(node: FloatNumber) -> LiteralToken {
LiteralToken::FloatNumber(node)
}
}
impl From<String> for LiteralToken {
fn from(node: String) -> LiteralToken {
LiteralToken::String(node)
}
}
impl From<RawString> for LiteralToken {
fn from(node: RawString) -> LiteralToken {
LiteralToken::RawString(node)
}
}
impl From<TrueKw> for LiteralToken {
fn from(node: TrueKw) -> LiteralToken {
LiteralToken::TrueKw(node)
}
}
impl From<FalseKw> for LiteralToken {
fn from(node: FalseKw) -> LiteralToken {
LiteralToken::FalseKw(node)
}
}
impl From<ByteString> for LiteralToken {
fn from(node: ByteString) -> LiteralToken {
LiteralToken::ByteString(node)
}
}
impl From<RawByteString> for LiteralToken {
fn from(node: RawByteString) -> LiteralToken {
LiteralToken::RawByteString(node)
}
}
impl From<Char> for LiteralToken {
fn from(node: Char) -> LiteralToken {
LiteralToken::Char(node)
}
}
impl From<Byte> for LiteralToken {
fn from(node: Byte) -> LiteralToken {
LiteralToken::Byte(node)
}
}
impl std::fmt::Display for LiteralToken {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstToken for LiteralToken {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING
| RAW_BYTE_STRING | CHAR | BYTE => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
let res = match syntax.kind() {
INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }),
FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
STRING => LiteralToken::String(String { syntax }),
RAW_STRING => LiteralToken::RawString(RawString { syntax }),
TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }),
FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }),
BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
CHAR => LiteralToken::Char(Char { syntax }),
BYTE => LiteralToken::Byte(Byte { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxToken {
match self {
LiteralToken::IntNumber(it) => &it.syntax,
LiteralToken::FloatNumber(it) => &it.syntax,
LiteralToken::String(it) => &it.syntax,
LiteralToken::RawString(it) => &it.syntax,
LiteralToken::TrueKw(it) => &it.syntax,
LiteralToken::FalseKw(it) => &it.syntax,
LiteralToken::ByteString(it) => &it.syntax,
LiteralToken::RawByteString(it) => &it.syntax,
LiteralToken::Char(it) => &it.syntax,
LiteralToken::Byte(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum NameRefToken {
Ident(Ident),
IntNumber(IntNumber),
}
impl From<Ident> for NameRefToken {
fn from(node: Ident) -> NameRefToken {
NameRefToken::Ident(node)
}
}
impl From<IntNumber> for NameRefToken {
fn from(node: IntNumber) -> NameRefToken {
NameRefToken::IntNumber(node)
}
}
impl std::fmt::Display for NameRefToken {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstToken for NameRefToken {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
IDENT | INT_NUMBER => true,
_ => false,
}
}
fn cast(syntax: SyntaxToken) -> Option<Self> {
let res = match syntax.kind() {
IDENT => NameRefToken::Ident(Ident { syntax }),
INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxToken {
match self {
NameRefToken::Ident(it) => &it.syntax,
NameRefToken::IntNumber(it) => &it.syntax,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum FieldDefList {
RecordFieldDefList(RecordFieldDefList),
TupleFieldDefList(TupleFieldDefList),
}
impl From<RecordFieldDefList> for FieldDefList {
fn from(node: RecordFieldDefList) -> FieldDefList {
FieldDefList::RecordFieldDefList(node)
}
}
impl From<TupleFieldDefList> for FieldDefList {
fn from(node: TupleFieldDefList) -> FieldDefList {
FieldDefList::TupleFieldDefList(node)
}
}
impl std::fmt::Display for FieldDefList {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
impl AstNode for FieldDefList {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
RECORD_FIELD_DEF_LIST => {
FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax })
}
TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }),
_ => return None,
};
Some(res)
}
fn syntax(&self) -> &SyntaxNode {
match self {
FieldDefList::RecordFieldDefList(it) => &it.syntax,
FieldDefList::TupleFieldDefList(it) => &it.syntax,
}
2018-08-27 09:22:09 +00:00
}
}