@@ -365,7 +365,7 @@ impl MavEnum {
365
365
366
366
#[ cfg( feature = "emit-description" ) ]
367
367
let description = if let Some ( description) = self . description . as_ref ( ) {
368
- let desc = format ! ( "{ description}" ) ;
368
+ let desc = description. to_string ( ) ;
369
369
quote ! ( #[ doc = #desc] )
370
370
} else {
371
371
quote ! ( )
@@ -1001,7 +1001,7 @@ pub enum MavXmlElement {
1001
1001
Extensions ,
1002
1002
}
1003
1003
1004
- fn identify_element ( s : & [ u8 ] ) -> Option < MavXmlElement > {
1004
+ const fn identify_element ( s : & [ u8 ] ) -> Option < MavXmlElement > {
1005
1005
use self :: MavXmlElement :: * ;
1006
1006
match s {
1007
1007
b"version" => Some ( Version ) ,
@@ -1066,7 +1066,7 @@ pub fn parse_profile(
1066
1066
let mut events: Vec < Result < Event , quick_xml:: Error > > = Vec :: new ( ) ;
1067
1067
let file = File :: open ( & in_path) . map_err ( |e| BindGenError :: CouldNotReadDefinitionFile {
1068
1068
source : e,
1069
- path : in_path. to_path_buf ( ) ,
1069
+ path : in_path. clone ( ) ,
1070
1070
} ) ?;
1071
1071
let mut reader = Reader :: from_reader ( BufReader :: new ( file) ) ;
1072
1072
reader. config_mut ( ) . trim_text ( true ) ;
@@ -1088,14 +1088,11 @@ pub fn parse_profile(
1088
1088
for e in events {
1089
1089
match e {
1090
1090
Ok ( Event :: Start ( bytes) ) => {
1091
- let id = match identify_element ( bytes. name ( ) . into_inner ( ) ) {
1092
- None => {
1093
- panic ! (
1094
- "unexpected element {:?}" ,
1095
- String :: from_utf8_lossy( bytes. name( ) . into_inner( ) )
1096
- ) ;
1097
- }
1098
- Some ( kind) => kind,
1091
+ let Some ( id) = identify_element ( bytes. name ( ) . into_inner ( ) ) else {
1092
+ panic ! (
1093
+ "unexpected element {:?}" ,
1094
+ String :: from_utf8_lossy( bytes. name( ) . into_inner( ) )
1095
+ ) ;
1099
1096
} ;
1100
1097
1101
1098
assert ! (
@@ -1109,20 +1106,20 @@ pub fn parse_profile(
1109
1106
is_in_extension = true ;
1110
1107
}
1111
1108
MavXmlElement :: Message => {
1112
- message = Default :: default ( ) ;
1109
+ message = MavMessage :: default ( ) ;
1113
1110
}
1114
1111
MavXmlElement :: Field => {
1115
- field = Default :: default ( ) ;
1112
+ field = MavField :: default ( ) ;
1116
1113
field. is_extension = is_in_extension;
1117
1114
}
1118
1115
MavXmlElement :: Enum => {
1119
- mavenum = Default :: default ( ) ;
1116
+ mavenum = MavEnum :: default ( ) ;
1120
1117
}
1121
1118
MavXmlElement :: Entry => {
1122
- entry = Default :: default ( ) ;
1119
+ entry = MavEnumEntry :: default ( ) ;
1123
1120
}
1124
1121
MavXmlElement :: Include => {
1125
- include = Default :: default ( ) ;
1122
+ include = PathBuf :: default ( ) ;
1126
1123
}
1127
1124
MavXmlElement :: Param => {
1128
1125
paramid = None ;
@@ -1237,7 +1234,7 @@ pub fn parse_profile(
1237
1234
if entry. params . is_none ( ) {
1238
1235
entry. params = Some ( vec ! [ ] ) ;
1239
1236
}
1240
- if let b"index" = attr. key . into_inner ( ) {
1237
+ if attr. key . into_inner ( ) == b"index" {
1241
1238
let s = std:: str:: from_utf8 ( & attr. value ) . unwrap ( ) ;
1242
1239
paramid = Some ( s. parse :: < usize > ( ) . unwrap ( ) ) ;
1243
1240
}
@@ -1251,7 +1248,7 @@ pub fn parse_profile(
1251
1248
is_in_extension = true ;
1252
1249
}
1253
1250
b"entry" => {
1254
- entry = Default :: default ( ) ;
1251
+ entry = MavEnumEntry :: default ( ) ;
1255
1252
for attr in bytes. attributes ( ) {
1256
1253
let attr = attr. unwrap ( ) ;
1257
1254
match attr. key . into_inner ( ) {
@@ -1311,7 +1308,7 @@ pub fn parse_profile(
1311
1308
eprintln ! ( "TODO: deprecated {s:?}" ) ;
1312
1309
}
1313
1310
data => {
1314
- panic ! ( "unexpected text data {:?} reading {:?}" , data , s ) ;
1311
+ panic ! ( "unexpected text data {data :?} reading {s :?}" ) ;
1315
1312
}
1316
1313
}
1317
1314
}
@@ -1489,7 +1486,7 @@ impl MavXmlFilter {
1489
1486
}
1490
1487
!self . extension_filter . is_in
1491
1488
}
1492
- Err ( error) => panic ! ( "Failed to filter XML: {}" , error ) ,
1489
+ Err ( error) => panic ! ( "Failed to filter XML: {error}" ) ,
1493
1490
}
1494
1491
}
1495
1492
}
0 commit comments