@@ -722,9 +722,19 @@ impl LetStmt {
722
722
pub fn ty ( & self ) -> Option < Type > { support:: child ( & self . syntax ) }
723
723
pub fn eq_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ =] ) }
724
724
pub fn initializer ( & self ) -> Option < Expr > { support:: child ( & self . syntax ) }
725
+ pub fn let_else ( & self ) -> Option < LetElse > { support:: child ( & self . syntax ) }
725
726
pub fn semicolon_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ; ] ) }
726
727
}
727
728
729
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
730
+ pub struct LetElse {
731
+ pub ( crate ) syntax : SyntaxNode ,
732
+ }
733
+ impl LetElse {
734
+ pub fn else_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ else] ) }
735
+ pub fn block_expr ( & self ) -> Option < BlockExpr > { support:: child ( & self . syntax ) }
736
+ }
737
+
728
738
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
729
739
pub struct ArrayExpr {
730
740
pub ( crate ) syntax : SyntaxNode ,
@@ -2304,6 +2314,17 @@ impl AstNode for LetStmt {
2304
2314
}
2305
2315
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2306
2316
}
2317
+ impl AstNode for LetElse {
2318
+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == LET_ELSE }
2319
+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
2320
+ if Self :: can_cast ( syntax. kind ( ) ) {
2321
+ Some ( Self { syntax } )
2322
+ } else {
2323
+ None
2324
+ }
2325
+ }
2326
+ fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
2327
+ }
2307
2328
impl AstNode for ArrayExpr {
2308
2329
fn can_cast ( kind : SyntaxKind ) -> bool { kind == ARRAY_EXPR }
2309
2330
fn cast ( syntax : SyntaxNode ) -> Option < Self > {
@@ -4320,6 +4341,11 @@ impl std::fmt::Display for LetStmt {
4320
4341
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4321
4342
}
4322
4343
}
4344
+ impl std:: fmt:: Display for LetElse {
4345
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4346
+ std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
4347
+ }
4348
+ }
4323
4349
impl std:: fmt:: Display for ArrayExpr {
4324
4350
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4325
4351
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
0 commit comments