@@ -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. trim_text ( true ) ;
@@ -1089,14 +1089,11 @@ pub fn parse_profile(
1089
1089
for e in events {
1090
1090
match e {
1091
1091
Ok ( Event :: Start ( bytes) ) => {
1092
- let id = match identify_element ( bytes. name ( ) . into_inner ( ) ) {
1093
- None => {
1094
- panic ! (
1095
- "unexpected element {:?}" ,
1096
- String :: from_utf8_lossy( bytes. name( ) . into_inner( ) )
1097
- ) ;
1098
- }
1099
- Some ( kind) => kind,
1092
+ let Some ( id) = identify_element ( bytes. name ( ) . into_inner ( ) ) else {
1093
+ panic ! (
1094
+ "unexpected element {:?}" ,
1095
+ String :: from_utf8_lossy( bytes. name( ) . into_inner( ) )
1096
+ ) ;
1100
1097
} ;
1101
1098
1102
1099
assert ! (
@@ -1110,20 +1107,20 @@ pub fn parse_profile(
1110
1107
is_in_extension = true ;
1111
1108
}
1112
1109
MavXmlElement :: Message => {
1113
- message = Default :: default ( ) ;
1110
+ message = MavMessage :: default ( ) ;
1114
1111
}
1115
1112
MavXmlElement :: Field => {
1116
- field = Default :: default ( ) ;
1113
+ field = MavField :: default ( ) ;
1117
1114
field. is_extension = is_in_extension;
1118
1115
}
1119
1116
MavXmlElement :: Enum => {
1120
- mavenum = Default :: default ( ) ;
1117
+ mavenum = MavEnum :: default ( ) ;
1121
1118
}
1122
1119
MavXmlElement :: Entry => {
1123
- entry = Default :: default ( ) ;
1120
+ entry = MavEnumEntry :: default ( ) ;
1124
1121
}
1125
1122
MavXmlElement :: Include => {
1126
- include = Default :: default ( ) ;
1123
+ include = PathBuf :: default ( ) ;
1127
1124
}
1128
1125
MavXmlElement :: Param => {
1129
1126
paramid = None ;
@@ -1238,7 +1235,7 @@ pub fn parse_profile(
1238
1235
if entry. params . is_none ( ) {
1239
1236
entry. params = Some ( vec ! [ ] ) ;
1240
1237
}
1241
- if let b"index" = attr. key . into_inner ( ) {
1238
+ if attr. key . into_inner ( ) == b"index" {
1242
1239
let s = std:: str:: from_utf8 ( & attr. value ) . unwrap ( ) ;
1243
1240
paramid = Some ( s. parse :: < usize > ( ) . unwrap ( ) ) ;
1244
1241
}
@@ -1252,7 +1249,7 @@ pub fn parse_profile(
1252
1249
is_in_extension = true ;
1253
1250
}
1254
1251
b"entry" => {
1255
- entry = Default :: default ( ) ;
1252
+ entry = MavEnumEntry :: default ( ) ;
1256
1253
for attr in bytes. attributes ( ) {
1257
1254
let attr = attr. unwrap ( ) ;
1258
1255
match attr. key . into_inner ( ) {
@@ -1312,7 +1309,7 @@ pub fn parse_profile(
1312
1309
eprintln ! ( "TODO: deprecated {s:?}" ) ;
1313
1310
}
1314
1311
data => {
1315
- panic ! ( "unexpected text data {:?} reading {:?}" , data , s ) ;
1312
+ panic ! ( "unexpected text data {data :?} reading {s :?}" ) ;
1316
1313
}
1317
1314
}
1318
1315
}
@@ -1490,7 +1487,7 @@ impl MavXmlFilter {
1490
1487
}
1491
1488
!self . extension_filter . is_in
1492
1489
}
1493
- Err ( error) => panic ! ( "Failed to filter XML: {}" , error ) ,
1490
+ Err ( error) => panic ! ( "Failed to filter XML: {error}" ) ,
1494
1491
}
1495
1492
}
1496
1493
}
0 commit comments