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<'_> {
1110
1110
/// (including '_') and does not start with a digit.
1111
1111
pub ( crate ) fn is_valid_identifier ( name : & str ) -> bool {
1112
1112
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 == '_' ) ;
1117
1115
1118
1116
first_valid && chars. all ( |c| c. is_alphanumeric ( ) || c == '_' )
1119
1117
}
Original file line number Diff line number Diff line change @@ -5145,14 +5145,10 @@ pub(crate) mod utils {
5145
5145
return Ok ( ( ) ) ;
5146
5146
}
5147
5147
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
+ ) ;
5156
5152
5157
5153
let dir = path. parent ( ) . unwrap ( ) ;
5158
5154
Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ use super::{CodegenError, WrapAsVariadic};
14
14
15
15
fn get_loc ( item : & Item ) -> String {
16
16
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 ( ) )
19
18
}
20
19
21
20
pub ( super ) trait CSerialize < ' a > {
Original file line number Diff line number Diff line change @@ -786,16 +786,14 @@ impl Item {
786
786
787
787
match * self . kind ( ) {
788
788
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
+ ) ,
799
797
ItemKind :: Function ( ref fun) => {
800
798
let mut name = fun. name ( ) . to_owned ( ) ;
801
799
@@ -1702,8 +1700,7 @@ impl Item {
1702
1700
ty. spelling( )
1703
1701
) ;
1704
1702
Item :: type_param ( Some ( id) , location, ctx)
1705
- . map ( Ok )
1706
- . unwrap_or ( Err ( ParseError :: Recurse ) )
1703
+ . ok_or ( ParseError :: Recurse )
1707
1704
} else {
1708
1705
result
1709
1706
}
Original file line number Diff line number Diff line change @@ -705,7 +705,7 @@ where
705
705
}
706
706
707
707
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 ) &&
709
709
self . regex_set . matches ( info. name )
710
710
{
711
711
return self . derives . clone ( ) ;
@@ -745,7 +745,7 @@ where
745
745
}
746
746
747
747
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 ) &&
749
749
self . regex_set . matches ( info. name )
750
750
{
751
751
return self . attributes . clone ( ) ;
You can’t perform that action at this time.
0 commit comments