@@ -6303,13 +6303,22 @@ impl ast::DocCommentsOwner for EnumVariant {}
63036303impl ast::AttrsOwner for EnumVariant {}
63046304impl EnumVariant {
63056305 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()
63076311 }
63086312 pub fn eq(&self) -> Option<Eq> {
63096313 self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
63106314 }
63116315 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()
63136322 }
63146323}
63156324#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6572,19 +6581,37 @@ impl ast::DocCommentsOwner for ConstDef {}
65726581impl ast::TypeAscriptionOwner for ConstDef {}
65736582impl ConstDef {
65746583 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()
65766589 }
65776590 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()
65796596 }
65806597 pub fn eq(&self) -> Option<Eq> {
65816598 self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
65826599 }
65836600 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()
65856607 }
65866608 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()
65886615 }
65896616}
65906617#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6646,19 +6673,37 @@ impl ast::DocCommentsOwner for StaticDef {}
66466673impl ast::TypeAscriptionOwner for StaticDef {}
66476674impl StaticDef {
66486675 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()
66506681 }
66516682 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()
66536688 }
66546689 pub fn eq(&self) -> Option<Eq> {
66556690 self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
66566691 }
66576692 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()
66596699 }
66606700 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()
66626707 }
66636708}
66646709#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -6720,19 +6765,37 @@ impl ast::DocCommentsOwner for TypeAliasDef {}
67206765impl ast::TypeBoundsOwner for TypeAliasDef {}
67216766impl TypeAliasDef {
67226767 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()
67246773 }
67256774 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()
67276780 }
67286781 pub fn eq(&self) -> Option<Eq> {
67296782 self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
67306783 }
67316784 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()
67336791 }
67346792 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()
67366799 }
67376800}
67386801#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -8157,16 +8220,29 @@ impl ast::AttrsOwner for ForExpr {}
81578220impl ast::LoopBodyOwner for ForExpr {}
81588221impl ForExpr {
81598222 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()
81618228 }
81628229 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()
81648235 }
81658236 pub fn in_kw(&self) -> Option<InKw> {
81668237 self.syntax.children_with_tokens().filter_map(InKw::cast_element).next()
81678238 }
81688239 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()
81708246 }
81718247}
81728248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -9498,16 +9574,29 @@ impl AstElement for MatchArm {
94989574impl ast::AttrsOwner for MatchArm {}
94999575impl MatchArm {
95009576 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()
95029582 }
95039583 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()
95059589 }
95069590 pub fn fat_arrow(&self) -> Option<FatArrow> {
95079591 self.syntax.children_with_tokens().filter_map(FatArrow::cast_element).next()
95089592 }
95099593 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()
95119600 }
95129601}
95139602#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -11753,16 +11842,29 @@ impl ast::AttrsOwner for LetStmt {}
1175311842impl ast::TypeAscriptionOwner for LetStmt {}
1175411843impl LetStmt {
1175511844 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()
1175711850 }
1175811851 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()
1176011857 }
1176111858 pub fn eq(&self) -> Option<Eq> {
1176211859 self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
1176311860 }
1176411861 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()
1176611868 }
1176711869}
1176811870#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -11820,15 +11922,9 @@ impl Condition {
1182011922 pub fn let_kw(&self) -> Option<LetKw> {
1182111923 self.syntax.children_with_tokens().filter_map(LetKw::cast_element).next()
1182211924 }
11823- pub fn pat(&self) -> Option<Pat> {
11824- self.syntax.children().filter_map(Pat::cast).next()
11825- }
1182611925 pub fn eq(&self) -> Option<Eq> {
1182711926 self.syntax.children_with_tokens().filter_map(Eq::cast_element).next()
1182811927 }
11829- pub fn expr(&self) -> Option<Expr> {
11830- self.syntax.children().filter_map(Expr::cast).next()
11831- }
1183211928}
1183311929#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1183411930pub struct Block {
0 commit comments