@@ -1993,13 +1993,15 @@ pub struct TypeBound {
1993
1993
pub ( crate ) syntax : SyntaxNode ,
1994
1994
}
1995
1995
impl TypeBound {
1996
- #[ inline]
1997
- pub fn generic_param_list ( & self ) -> Option < GenericParamList > { support:: child ( & self . syntax ) }
1998
1996
#[ inline]
1999
1997
pub fn lifetime ( & self ) -> Option < Lifetime > { support:: child ( & self . syntax ) }
2000
1998
#[ inline]
2001
1999
pub fn ty ( & self ) -> Option < Type > { support:: child ( & self . syntax ) }
2002
2000
#[ inline]
2001
+ pub fn use_bound_generic_args ( & self ) -> Option < UseBoundGenericArgs > {
2002
+ support:: child ( & self . syntax )
2003
+ }
2004
+ #[ inline]
2003
2005
pub fn question_mark_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ ?] ) }
2004
2006
#[ inline]
2005
2007
pub fn async_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ async ] ) }
@@ -2076,6 +2078,21 @@ impl Use {
2076
2078
pub fn use_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ use ] ) }
2077
2079
}
2078
2080
2081
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
2082
+ pub struct UseBoundGenericArgs {
2083
+ pub ( crate ) syntax : SyntaxNode ,
2084
+ }
2085
+ impl UseBoundGenericArgs {
2086
+ #[ inline]
2087
+ pub fn use_bound_generic_args ( & self ) -> AstChildren < UseBoundGenericArg > {
2088
+ support:: children ( & self . syntax )
2089
+ }
2090
+ #[ inline]
2091
+ pub fn l_angle_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ <] ) }
2092
+ #[ inline]
2093
+ pub fn r_angle_token ( & self ) -> Option < SyntaxToken > { support:: token ( & self . syntax , T ! [ >] ) }
2094
+ }
2095
+
2079
2096
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
2080
2097
pub struct UseTree {
2081
2098
pub ( crate ) syntax : SyntaxNode ,
@@ -2402,6 +2419,12 @@ pub enum Type {
2402
2419
TupleType ( TupleType ) ,
2403
2420
}
2404
2421
2422
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
2423
+ pub enum UseBoundGenericArg {
2424
+ Lifetime ( Lifetime ) ,
2425
+ NameRef ( NameRef ) ,
2426
+ }
2427
+
2405
2428
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
2406
2429
pub struct AnyHasArgList {
2407
2430
pub ( crate ) syntax : SyntaxNode ,
@@ -4435,6 +4458,20 @@ impl AstNode for Use {
4435
4458
#[ inline]
4436
4459
fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
4437
4460
}
4461
+ impl AstNode for UseBoundGenericArgs {
4462
+ #[ inline]
4463
+ fn can_cast ( kind : SyntaxKind ) -> bool { kind == USE_BOUND_GENERIC_ARGS }
4464
+ #[ inline]
4465
+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
4466
+ if Self :: can_cast ( syntax. kind ( ) ) {
4467
+ Some ( Self { syntax } )
4468
+ } else {
4469
+ None
4470
+ }
4471
+ }
4472
+ #[ inline]
4473
+ fn syntax ( & self ) -> & SyntaxNode { & self . syntax }
4474
+ }
4438
4475
impl AstNode for UseTree {
4439
4476
#[ inline]
4440
4477
fn can_cast ( kind : SyntaxKind ) -> bool { kind == USE_TREE }
@@ -5560,6 +5597,34 @@ impl AstNode for Type {
5560
5597
}
5561
5598
}
5562
5599
}
5600
+ impl From < Lifetime > for UseBoundGenericArg {
5601
+ #[ inline]
5602
+ fn from ( node : Lifetime ) -> UseBoundGenericArg { UseBoundGenericArg :: Lifetime ( node) }
5603
+ }
5604
+ impl From < NameRef > for UseBoundGenericArg {
5605
+ #[ inline]
5606
+ fn from ( node : NameRef ) -> UseBoundGenericArg { UseBoundGenericArg :: NameRef ( node) }
5607
+ }
5608
+ impl AstNode for UseBoundGenericArg {
5609
+ #[ inline]
5610
+ fn can_cast ( kind : SyntaxKind ) -> bool { matches ! ( kind, LIFETIME | NAME_REF ) }
5611
+ #[ inline]
5612
+ fn cast ( syntax : SyntaxNode ) -> Option < Self > {
5613
+ let res = match syntax. kind ( ) {
5614
+ LIFETIME => UseBoundGenericArg :: Lifetime ( Lifetime { syntax } ) ,
5615
+ NAME_REF => UseBoundGenericArg :: NameRef ( NameRef { syntax } ) ,
5616
+ _ => return None ,
5617
+ } ;
5618
+ Some ( res)
5619
+ }
5620
+ #[ inline]
5621
+ fn syntax ( & self ) -> & SyntaxNode {
5622
+ match self {
5623
+ UseBoundGenericArg :: Lifetime ( it) => & it. syntax ,
5624
+ UseBoundGenericArg :: NameRef ( it) => & it. syntax ,
5625
+ }
5626
+ }
5627
+ }
5563
5628
impl AnyHasArgList {
5564
5629
#[ inline]
5565
5630
pub fn new < T : ast:: HasArgList > ( node : T ) -> AnyHasArgList {
@@ -6570,6 +6635,11 @@ impl std::fmt::Display for Type {
6570
6635
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
6571
6636
}
6572
6637
}
6638
+ impl std:: fmt:: Display for UseBoundGenericArg {
6639
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
6640
+ std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
6641
+ }
6642
+ }
6573
6643
impl std:: fmt:: Display for Abi {
6574
6644
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
6575
6645
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
@@ -7275,6 +7345,11 @@ impl std::fmt::Display for Use {
7275
7345
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
7276
7346
}
7277
7347
}
7348
+ impl std:: fmt:: Display for UseBoundGenericArgs {
7349
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
7350
+ std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
7351
+ }
7352
+ }
7278
7353
impl std:: fmt:: Display for UseTree {
7279
7354
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
7280
7355
std:: fmt:: Display :: fmt ( self . syntax ( ) , f)
0 commit comments