This repository was archived by the owner on May 28, 2025. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 4 files changed +10
-10
lines changed Expand file tree Collapse file tree 4 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ pub struct Path {
100100impl  PartialEq < Symbol >  for  Path  { 
101101    #[ inline]  
102102    fn  eq ( & self ,  symbol :  & Symbol )  -> bool  { 
103-         self . segments . len ( )  ==  1  &&  {   self . segments [ 0 ] . ident . name  == * symbol  } 
103+         matches ! ( & self . segments[ .. ] ,   [ segment ]   if  segment . ident. name == * symbol) 
104104    } 
105105} 
106106
@@ -121,13 +121,13 @@ impl Path {
121121    } 
122122
123123    pub  fn  is_global ( & self )  -> bool  { 
124-         ! self . segments . is_empty ( )  &&  self . segments [ 0 ] . ident . name  == kw:: PathRoot 
124+         self . segments . first ( ) . is_some_and ( |segment| segment . ident . name  == kw:: PathRoot ) 
125125    } 
126126
127127    /// If this path is a single identifier with no arguments, does not ensure 
128128/// that the path resolves to a const param, the caller should check this. 
129129pub  fn  is_potential_trivial_const_arg ( & self )  -> bool  { 
130-         self . segments . len ( )  ==  1  &&  self . segments [ 0 ] . args . is_none ( ) 
130+         matches ! ( self . segments[ .. ] ,   [ PathSegment   {  args :   None ,  ..  } ] ) 
131131    } 
132132} 
133133
Original file line number Diff line number Diff line change @@ -302,7 +302,7 @@ impl AttrItem {
302302impl  MetaItem  { 
303303    /// For a single-segment meta item, returns its name; otherwise, returns `None`. 
304304pub  fn  ident ( & self )  -> Option < Ident >  { 
305-         if  self . path . segments . len ( )  ==  1   {   Some ( self . path . segments [ 0 ] . ident )  }  else  {  None  } 
305+         if  let   [ PathSegment   {  ident ,  ..  } ]  =  self . path . segments [ .. ]   {   Some ( ident)  }  else  {  None  } 
306306    } 
307307
308308    pub  fn  name_or_empty ( & self )  -> Symbol  { 
Original file line number Diff line number Diff line change @@ -1813,10 +1813,10 @@ pub fn walk_flat_map_stmt<T: MutVisitor>(
18131813        . into_iter ( ) 
18141814        . map ( |kind| Stmt  {  id,  kind,  span } ) 
18151815        . collect ( ) ; 
1816-     match  stmts. len ( )  { 
1817-         0  => { } 
1818-         1  => vis. visit_span ( & mut  stmts [ 0 ] . span ) , 
1819-         2 ..  => panic ! ( 
1816+     match  & mut   stmts[ .. ]  { 
1817+         [ ]  => { } 
1818+         [ stmt ]  => vis. visit_span ( & mut  stmt . span ) , 
1819+         _  => panic ! ( 
18201820            "cloning statement `NodeId`s is prohibited by default, \  
18211821
18221822        ) , 
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
3939        let  mut  i = 0 ; 
4040        let  mut  j = lines. len ( ) ; 
4141        // first line of all-stars should be omitted 
42-         if  ! lines. is_empty ( )  && lines [ 0 ] . chars ( ) . all ( |c| c == '*' )  { 
42+         if  lines. first ( ) . is_some_and ( |line| line . chars ( ) . all ( |c| c == '*' ) )  { 
4343            i += 1 ; 
4444        } 
4545
@@ -97,7 +97,7 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
9797                return  None ; 
9898            } 
9999        } 
100-         if   lines. is_empty ( )   {   None   }   else   {   Some ( lines [ 0 ] [ ..i] . into ( ) )   } 
100+         Some ( lines. first ( ) ? [ ..i] . to_string ( ) ) 
101101    } 
102102
103103    let  data_s = data. as_str ( ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments