File tree Expand file tree Collapse file tree 5 files changed +18
-28
lines changed
Expand file tree Collapse file tree 5 files changed +18
-28
lines changed Original file line number Diff line number Diff line change @@ -1110,10 +1110,8 @@ impl Iterator for ClangTokenIterator<'_> {
11101110/// (including '_') and does not start with a digit.
11111111pub ( crate ) fn is_valid_identifier ( name : & str ) -> bool {
11121112 let mut chars = name. chars ( ) ;
1113- let first_valid = chars
1114- . next ( )
1115- . map ( |c| c. is_alphabetic ( ) || c == '_' )
1116- . unwrap_or ( false ) ;
1113+ let first_valid =
1114+ chars. next ( ) . is_some_and ( |c| c. is_alphabetic ( ) || c == '_' ) ;
11171115
11181116 first_valid && chars. all ( |c| c. is_alphanumeric ( ) || c == '_' )
11191117}
Original file line number Diff line number Diff line change @@ -5145,14 +5145,10 @@ pub(crate) mod utils {
51455145 return Ok ( ( ) ) ;
51465146 }
51475147
5148- let path = context
5149- . options ( )
5150- . wrap_static_fns_path
5151- . as_ref ( )
5152- . map ( PathBuf :: from)
5153- . unwrap_or_else ( || {
5154- std:: env:: temp_dir ( ) . join ( "bindgen" ) . join ( "extern" )
5155- } ) ;
5148+ let path = context. options ( ) . wrap_static_fns_path . as_ref ( ) . map_or_else (
5149+ || std:: env:: temp_dir ( ) . join ( "bindgen" ) . join ( "extern" ) ,
5150+ PathBuf :: from,
5151+ ) ;
51565152
51575153 let dir = path. parent ( ) . unwrap ( ) ;
51585154
Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ use super::{CodegenError, WrapAsVariadic};
1414
1515fn get_loc ( item : & Item ) -> String {
1616 item. location ( )
17- . map ( |x| x. to_string ( ) )
18- . unwrap_or_else ( || "unknown" . to_owned ( ) )
17+ . map_or_else ( || "unknown" . to_owned ( ) , |x| x. to_string ( ) )
1918}
2019
2120pub ( super ) trait CSerialize < ' a > {
Original file line number Diff line number Diff line change @@ -786,16 +786,14 @@ impl Item {
786786
787787 match * self . kind ( ) {
788788 ItemKind :: Var ( ref var) => var. name ( ) . to_owned ( ) ,
789- ItemKind :: Module ( ref module) => {
790- module. name ( ) . map ( ToOwned :: to_owned) . unwrap_or_else ( || {
791- format ! ( "_bindgen_mod_{}" , self . exposed_id( ctx) )
792- } )
793- }
794- ItemKind :: Type ( ref ty) => {
795- ty. sanitized_name ( ctx) . map ( Into :: into) . unwrap_or_else ( || {
796- format ! ( "_bindgen_ty_{}" , self . exposed_id( ctx) )
797- } )
798- }
789+ ItemKind :: Module ( ref module) => module. name ( ) . map_or_else (
790+ || format ! ( "_bindgen_mod_{}" , self . exposed_id( ctx) ) ,
791+ ToOwned :: to_owned,
792+ ) ,
793+ ItemKind :: Type ( ref ty) => ty. sanitized_name ( ctx) . map_or_else (
794+ || format ! ( "_bindgen_ty_{}" , self . exposed_id( ctx) ) ,
795+ Into :: into,
796+ ) ,
799797 ItemKind :: Function ( ref fun) => {
800798 let mut name = fun. name ( ) . to_owned ( ) ;
801799
@@ -1702,8 +1700,7 @@ impl Item {
17021700 ty. spelling( )
17031701 ) ;
17041702 Item :: type_param ( Some ( id) , location, ctx)
1705- . map ( Ok )
1706- . unwrap_or ( Err ( ParseError :: Recurse ) )
1703+ . ok_or ( ParseError :: Recurse )
17071704 } else {
17081705 result
17091706 }
Original file line number Diff line number Diff line change @@ -705,7 +705,7 @@ where
705705 }
706706
707707 fn add_derives ( & self , info : & DeriveInfo < ' _ > ) -> Vec < String > {
708- if self . kind . map ( |kind| kind == info. kind ) . unwrap_or ( true ) &&
708+ if self . kind . map_or ( true , |kind| kind == info. kind ) &&
709709 self . regex_set . matches ( info. name )
710710 {
711711 return self . derives . clone ( ) ;
@@ -745,7 +745,7 @@ where
745745 }
746746
747747 fn add_attributes ( & self , info : & AttributeInfo < ' _ > ) -> Vec < String > {
748- if self . kind . map ( |kind| kind == info. kind ) . unwrap_or ( true ) &&
748+ if self . kind . map_or ( true , |kind| kind == info. kind ) &&
749749 self . regex_set . matches ( info. name )
750750 {
751751 return self . attributes . clone ( ) ;
You can’t perform that action at this time.
0 commit comments