@@ -6303,13 +6303,22 @@ impl ast::DocCommentsOwner for EnumVariant {}
6303
6303
impl ast::AttrsOwner for EnumVariant {}
6304
6304
impl EnumVariant {
6305
6305
pub fn field_def_list(&self) -> Option<FieldDefList> {
6306
- self.syntax.children().filter_map(FieldDefList::cast).next()
6306
+ self.syntax
6307
+ .children_with_tokens()
6308
+ .take_while(|x| !Eq::can_cast_element(x.kind()))
6309
+ .filter_map(FieldDefList::cast_element)
6310
+ .next()
6307
6311
}
6308
6312
pub fn eq(&self) -> Option<Eq> {
6309
6313
self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
6310
6314
}
6311
6315
pub fn expr(&self) -> Option<Expr> {
6312
- self.syntax.children().filter_map(Expr::cast).next()
6316
+ self.syntax
6317
+ .children_with_tokens()
6318
+ .skip_while(|x| !Eq::can_cast_element(x.kind()))
6319
+ .skip(1)
6320
+ .filter_map(Expr::cast_element)
6321
+ .next()
6313
6322
}
6314
6323
}
6315
6324
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6572,19 +6581,37 @@ impl ast::DocCommentsOwner for ConstDef {}
6572
6581
impl ast::TypeAscriptionOwner for ConstDef {}
6573
6582
impl ConstDef {
6574
6583
pub fn default_kw(&self) -> Option<DefaultKw> {
6575
- self.syntax.children_with_tokens().filter_map(DefaultKw::cast_element).next()
6584
+ self.syntax
6585
+ .children_with_tokens()
6586
+ .take_while(|x| !Eq::can_cast_element(x.kind()))
6587
+ .filter_map(DefaultKw::cast_element)
6588
+ .next()
6576
6589
}
6577
6590
pub fn const_kw(&self) -> Option<ConstKw> {
6578
- self.syntax.children_with_tokens().filter_map(ConstKw::cast_element).next()
6591
+ self.syntax
6592
+ .children_with_tokens()
6593
+ .take_while(|x| !Eq::can_cast_element(x.kind()))
6594
+ .filter_map(ConstKw::cast_element)
6595
+ .next()
6579
6596
}
6580
6597
pub fn eq(&self) -> Option<Eq> {
6581
6598
self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
6582
6599
}
6583
6600
pub fn body(&self) -> Option<Expr> {
6584
- self.syntax.children().filter_map(Expr::cast).next()
6601
+ self.syntax
6602
+ .children_with_tokens()
6603
+ .skip_while(|x| !Eq::can_cast_element(x.kind()))
6604
+ .skip(1)
6605
+ .filter_map(Expr::cast_element)
6606
+ .next()
6585
6607
}
6586
6608
pub fn semi(&self) -> Option<Semi> {
6587
- self.syntax.children_with_tokens().filter_map(Semi::cast_element).next()
6609
+ self.syntax
6610
+ .children_with_tokens()
6611
+ .skip_while(|x| !Eq::can_cast_element(x.kind()))
6612
+ .skip(1)
6613
+ .filter_map(Semi::cast_element)
6614
+ .next()
6588
6615
}
6589
6616
}
6590
6617
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6646,19 +6673,37 @@ impl ast::DocCommentsOwner for StaticDef {}
6646
6673
impl ast::TypeAscriptionOwner for StaticDef {}
6647
6674
impl StaticDef {
6648
6675
pub fn static_kw(&self) -> Option<StaticKw> {
6649
- self.syntax.children_with_tokens().filter_map(StaticKw::cast_element).next()
6676
+ self.syntax
6677
+ .children_with_tokens()
6678
+ .take_while(|x| !Eq::can_cast_element(x.kind()))
6679
+ .filter_map(StaticKw::cast_element)
6680
+ .next()
6650
6681
}
6651
6682
pub fn mut_kw(&self) -> Option<MutKw> {
6652
- self.syntax.children_with_tokens().filter_map(MutKw::cast_element).next()
6683
+ self.syntax
6684
+ .children_with_tokens()
6685
+ .take_while(|x| !Eq::can_cast_element(x.kind()))
6686
+ .filter_map(MutKw::cast_element)
6687
+ .next()
6653
6688
}
6654
6689
pub fn eq(&self) -> Option<Eq> {
6655
6690
self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
6656
6691
}
6657
6692
pub fn body(&self) -> Option<Expr> {
6658
- self.syntax.children().filter_map(Expr::cast).next()
6693
+ self.syntax
6694
+ .children_with_tokens()
6695
+ .skip_while(|x| !Eq::can_cast_element(x.kind()))
6696
+ .skip(1)
6697
+ .filter_map(Expr::cast_element)
6698
+ .next()
6659
6699
}
6660
6700
pub fn semi(&self) -> Option<Semi> {
6661
- self.syntax.children_with_tokens().filter_map(Semi::cast_element).next()
6701
+ self.syntax
6702
+ .children_with_tokens()
6703
+ .skip_while(|x| !Eq::can_cast_element(x.kind()))
6704
+ .skip(1)
6705
+ .filter_map(Semi::cast_element)
6706
+ .next()
6662
6707
}
6663
6708
}
6664
6709
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6720,19 +6765,37 @@ impl ast::DocCommentsOwner for TypeAliasDef {}
6720
6765
impl ast::TypeBoundsOwner for TypeAliasDef {}
6721
6766
impl TypeAliasDef {
6722
6767
pub fn default_kw(&self) -> Option<DefaultKw> {
6723
- self.syntax.children_with_tokens().filter_map(DefaultKw::cast_element).next()
6768
+ self.syntax
6769
+ .children_with_tokens()
6770
+ .take_while(|x| !Eq::can_cast_element(x.kind()))
6771
+ .filter_map(DefaultKw::cast_element)
6772
+ .next()
6724
6773
}
6725
6774
pub fn type_kw(&self) -> Option<TypeKw> {
6726
- self.syntax.children_with_tokens().filter_map(TypeKw::cast_element).next()
6775
+ self.syntax
6776
+ .children_with_tokens()
6777
+ .take_while(|x| !Eq::can_cast_element(x.kind()))
6778
+ .filter_map(TypeKw::cast_element)
6779
+ .next()
6727
6780
}
6728
6781
pub fn eq(&self) -> Option<Eq> {
6729
6782
self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
6730
6783
}
6731
6784
pub fn type_ref(&self) -> Option<TypeRef> {
6732
- self.syntax.children().filter_map(TypeRef::cast).next()
6785
+ self.syntax
6786
+ .children_with_tokens()
6787
+ .skip_while(|x| !Eq::can_cast_element(x.kind()))
6788
+ .skip(1)
6789
+ .filter_map(TypeRef::cast_element)
6790
+ .next()
6733
6791
}
6734
6792
pub fn semi(&self) -> Option<Semi> {
6735
- self.syntax.children_with_tokens().filter_map(Semi::cast_element).next()
6793
+ self.syntax
6794
+ .children_with_tokens()
6795
+ .skip_while(|x| !Eq::can_cast_element(x.kind()))
6796
+ .skip(1)
6797
+ .filter_map(Semi::cast_element)
6798
+ .next()
6736
6799
}
6737
6800
}
6738
6801
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -8157,16 +8220,29 @@ impl ast::AttrsOwner for ForExpr {}
8157
8220
impl ast::LoopBodyOwner for ForExpr {}
8158
8221
impl ForExpr {
8159
8222
pub fn for_kw(&self) -> Option<ForKw> {
8160
- self.syntax.children_with_tokens().filter_map(ForKw::cast_element).next()
8223
+ self.syntax
8224
+ .children_with_tokens()
8225
+ .take_while(|x| !InKw::can_cast_element(x.kind()))
8226
+ .filter_map(ForKw::cast_element)
8227
+ .next()
8161
8228
}
8162
8229
pub fn pat(&self) -> Option<Pat> {
8163
- self.syntax.children().filter_map(Pat::cast).next()
8230
+ self.syntax
8231
+ .children_with_tokens()
8232
+ .take_while(|x| !InKw::can_cast_element(x.kind()))
8233
+ .filter_map(Pat::cast_element)
8234
+ .next()
8164
8235
}
8165
8236
pub fn in_kw(&self) -> Option<InKw> {
8166
8237
self.syntax.children_with_tokens().filter_map(InKw::cast_element).next()
8167
8238
}
8168
8239
pub fn iterable(&self) -> Option<Expr> {
8169
- self.syntax.children().filter_map(Expr::cast).next()
8240
+ self.syntax
8241
+ .children_with_tokens()
8242
+ .skip_while(|x| !InKw::can_cast_element(x.kind()))
8243
+ .skip(1)
8244
+ .filter_map(Expr::cast_element)
8245
+ .next()
8170
8246
}
8171
8247
}
8172
8248
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -9498,16 +9574,29 @@ impl AstElement for MatchArm {
9498
9574
impl ast::AttrsOwner for MatchArm {}
9499
9575
impl MatchArm {
9500
9576
pub fn pat(&self) -> Option<Pat> {
9501
- self.syntax.children().filter_map(Pat::cast).next()
9577
+ self.syntax
9578
+ .children_with_tokens()
9579
+ .take_while(|x| !FatArrow::can_cast_element(x.kind()))
9580
+ .filter_map(Pat::cast_element)
9581
+ .next()
9502
9582
}
9503
9583
pub fn guard(&self) -> Option<MatchGuard> {
9504
- self.syntax.children().filter_map(MatchGuard::cast).next()
9584
+ self.syntax
9585
+ .children_with_tokens()
9586
+ .take_while(|x| !FatArrow::can_cast_element(x.kind()))
9587
+ .filter_map(MatchGuard::cast_element)
9588
+ .next()
9505
9589
}
9506
9590
pub fn fat_arrow(&self) -> Option<FatArrow> {
9507
9591
self.syntax.children_with_tokens().filter_map(FatArrow::cast_element).next()
9508
9592
}
9509
9593
pub fn expr(&self) -> Option<Expr> {
9510
- self.syntax.children().filter_map(Expr::cast).next()
9594
+ self.syntax
9595
+ .children_with_tokens()
9596
+ .skip_while(|x| !FatArrow::can_cast_element(x.kind()))
9597
+ .skip(1)
9598
+ .filter_map(Expr::cast_element)
9599
+ .next()
9511
9600
}
9512
9601
}
9513
9602
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -11753,16 +11842,29 @@ impl ast::AttrsOwner for LetStmt {}
11753
11842
impl ast::TypeAscriptionOwner for LetStmt {}
11754
11843
impl LetStmt {
11755
11844
pub fn let_kw(&self) -> Option<LetKw> {
11756
- self.syntax.children_with_tokens().filter_map(LetKw::cast_element).next()
11845
+ self.syntax
11846
+ .children_with_tokens()
11847
+ .take_while(|x| !Eq::can_cast_element(x.kind()))
11848
+ .filter_map(LetKw::cast_element)
11849
+ .next()
11757
11850
}
11758
11851
pub fn pat(&self) -> Option<Pat> {
11759
- self.syntax.children().filter_map(Pat::cast).next()
11852
+ self.syntax
11853
+ .children_with_tokens()
11854
+ .take_while(|x| !Eq::can_cast_element(x.kind()))
11855
+ .filter_map(Pat::cast_element)
11856
+ .next()
11760
11857
}
11761
11858
pub fn eq(&self) -> Option<Eq> {
11762
11859
self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
11763
11860
}
11764
11861
pub fn initializer(&self) -> Option<Expr> {
11765
- self.syntax.children().filter_map(Expr::cast).next()
11862
+ self.syntax
11863
+ .children_with_tokens()
11864
+ .skip_while(|x| !Eq::can_cast_element(x.kind()))
11865
+ .skip(1)
11866
+ .filter_map(Expr::cast_element)
11867
+ .next()
11766
11868
}
11767
11869
}
11768
11870
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -11820,15 +11922,9 @@ impl Condition {
11820
11922
pub fn let_kw(&self) -> Option<LetKw> {
11821
11923
self.syntax.children_with_tokens().filter_map(LetKw::cast_element).next()
11822
11924
}
11823
- pub fn pat(&self) -> Option<Pat> {
11824
- self.syntax.children().filter_map(Pat::cast).next()
11825
- }
11826
11925
pub fn eq(&self) -> Option<Eq> {
11827
11926
self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
11828
11927
}
11829
- pub fn expr(&self) -> Option<Expr> {
11830
- self.syntax.children().filter_map(Expr::cast).next()
11831
- }
11832
11928
}
11833
11929
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11834
11930
pub struct Block {
0 commit comments