@@ -137,7 +137,7 @@ impl Abbreviations {
137
137
let mut abbrevs = Abbreviations :: empty ( ) ;
138
138
139
139
loop {
140
- let ( rest, abbrev) = try! ( Abbreviation :: parse ( input) ) ;
140
+ let ( rest, abbrev) = Abbreviation :: parse ( input) ? ;
141
141
input = rest;
142
142
143
143
match abbrev {
@@ -210,7 +210,7 @@ impl Abbreviation {
210
210
211
211
/// Parse an abbreviation's tag.
212
212
fn parse_tag ( input : & [ u8 ] ) -> Result < ( & [ u8 ] , constants:: DwTag ) > {
213
- let ( rest, val) = try! ( parse_unsigned_leb ( input) ) ;
213
+ let ( rest, val) = parse_unsigned_leb ( input) ? ;
214
214
if val == 0 {
215
215
Err ( Error :: AbbreviationTagZero )
216
216
} else {
@@ -220,7 +220,7 @@ impl Abbreviation {
220
220
221
221
/// Parse an abbreviation's "does the type have children?" byte.
222
222
fn parse_has_children ( input : & [ u8 ] ) -> Result < ( & [ u8 ] , constants:: DwChildren ) > {
223
- let ( rest, val) = try! ( parse_u8 ( input) ) ;
223
+ let ( rest, val) = parse_u8 ( input) ? ;
224
224
let val = constants:: DwChildren ( val) ;
225
225
if val == constants:: DW_CHILDREN_no || val == constants:: DW_CHILDREN_yes {
226
226
Ok ( ( rest, val) )
@@ -235,7 +235,7 @@ impl Abbreviation {
235
235
let mut attrs = Vec :: new ( ) ;
236
236
237
237
loop {
238
- let ( rest, attr) = try! ( AttributeSpecification :: parse ( input) ) ;
238
+ let ( rest, attr) = AttributeSpecification :: parse ( input) ? ;
239
239
input = rest;
240
240
241
241
match attr {
@@ -250,14 +250,14 @@ impl Abbreviation {
250
250
/// Parse an abbreviation. Return `None` for the null abbreviation, `Some`
251
251
/// for an actual abbreviation.
252
252
fn parse ( input : & [ u8 ] ) -> Result < ( & [ u8 ] , Option < Abbreviation > ) > {
253
- let ( rest, code) = try! ( parse_unsigned_leb ( input) ) ;
253
+ let ( rest, code) = parse_unsigned_leb ( input) ? ;
254
254
if code == 0 {
255
255
return Ok ( ( rest, None ) ) ;
256
256
}
257
257
258
- let ( rest, tag) = try! ( Self :: parse_tag ( rest) ) ;
259
- let ( rest, has_children) = try! ( Self :: parse_has_children ( rest) ) ;
260
- let ( rest, attributes) = try! ( Self :: parse_attributes ( rest) ) ;
258
+ let ( rest, tag) = Self :: parse_tag ( rest) ? ;
259
+ let ( rest, has_children) = Self :: parse_has_children ( rest) ? ;
260
+ let ( rest, attributes) = Self :: parse_attributes ( rest) ? ;
261
261
let abbrev = Abbreviation :: new ( code, tag, has_children, attributes) ;
262
262
Ok ( ( rest, Some ( abbrev) ) )
263
263
}
@@ -345,7 +345,7 @@ impl AttributeSpecification {
345
345
346
346
/// Parse an attribute's form.
347
347
fn parse_form ( input : & [ u8 ] ) -> Result < ( & [ u8 ] , constants:: DwForm ) > {
348
- let ( rest, val) = try! ( parse_unsigned_leb ( input) ) ;
348
+ let ( rest, val) = parse_unsigned_leb ( input) ? ;
349
349
if val == 0 {
350
350
Err ( Error :: AttributeFormZero )
351
351
} else {
@@ -356,10 +356,10 @@ impl AttributeSpecification {
356
356
/// Parse an attribute specification. Returns `None` for the null attribute
357
357
/// specification, `Some` for an actual attribute specification.
358
358
fn parse ( input : & [ u8 ] ) -> Result < ( & [ u8 ] , Option < AttributeSpecification > ) > {
359
- let ( rest, name) = try! ( parse_unsigned_leb ( input) ) ;
359
+ let ( rest, name) = parse_unsigned_leb ( input) ? ;
360
360
if name == 0 {
361
361
// Parse the null attribute specification.
362
- let ( rest, form) = try! ( parse_unsigned_leb ( rest) ) ;
362
+ let ( rest, form) = parse_unsigned_leb ( rest) ? ;
363
363
return if form == 0 {
364
364
Ok ( ( rest, None ) )
365
365
} else {
@@ -368,7 +368,7 @@ impl AttributeSpecification {
368
368
}
369
369
370
370
let name = constants:: DwAt ( name) ;
371
- let ( rest, form) = try! ( Self :: parse_form ( rest) ) ;
371
+ let ( rest, form) = Self :: parse_form ( rest) ? ;
372
372
let spec = AttributeSpecification :: new ( name, form) ;
373
373
Ok ( ( rest, Some ( spec) ) )
374
374
}
@@ -440,11 +440,10 @@ pub mod tests {
440
440
AttributeSpecification :: new( constants:: DW_AT_language ,
441
441
constants:: DW_FORM_data2 ) ] ) ;
442
442
443
- let abbrev2 =
444
- Abbreviation :: new ( 2 ,
445
- constants:: DW_TAG_subprogram ,
446
- constants:: DW_CHILDREN_no ,
447
- vec ! [ AttributeSpecification :: new( constants:: DW_AT_name ,
443
+ let abbrev2 = Abbreviation :: new ( 2 ,
444
+ constants:: DW_TAG_subprogram ,
445
+ constants:: DW_CHILDREN_no ,
446
+ vec ! [ AttributeSpecification :: new( constants:: DW_AT_name ,
448
447
constants:: DW_FORM_string ) ] ) ;
449
448
450
449
let debug_abbrev = DebugAbbrev :: < LittleEndian > :: new ( & buf) ;
@@ -574,11 +573,10 @@ pub mod tests {
574
573
AttributeSpecification :: new( constants:: DW_AT_language ,
575
574
constants:: DW_FORM_data2 ) ] ) ;
576
575
577
- let abbrev2 =
578
- Abbreviation :: new ( 2 ,
579
- constants:: DW_TAG_subprogram ,
580
- constants:: DW_CHILDREN_no ,
581
- vec ! [ AttributeSpecification :: new( constants:: DW_AT_name ,
576
+ let abbrev2 = Abbreviation :: new ( 2 ,
577
+ constants:: DW_TAG_subprogram ,
578
+ constants:: DW_CHILDREN_no ,
579
+ vec ! [ AttributeSpecification :: new( constants:: DW_AT_name ,
582
580
constants:: DW_FORM_string ) ] ) ;
583
581
584
582
let ( rest, abbrevs) = Abbreviations :: parse ( & buf) . expect ( "Should parse abbreviations" ) ;
@@ -651,11 +649,10 @@ pub mod tests {
651
649
. get_contents ( )
652
650
. unwrap ( ) ;
653
651
654
- let expect =
655
- Some ( Abbreviation :: new ( 1 ,
656
- constants:: DW_TAG_subprogram ,
657
- constants:: DW_CHILDREN_no ,
658
- vec ! [ AttributeSpecification :: new( constants:: DW_AT_name ,
652
+ let expect = Some ( Abbreviation :: new ( 1 ,
653
+ constants:: DW_TAG_subprogram ,
654
+ constants:: DW_CHILDREN_no ,
655
+ vec ! [ AttributeSpecification :: new( constants:: DW_AT_name ,
659
656
constants:: DW_FORM_string ) ] ) ) ;
660
657
661
658
let ( rest, abbrev) = Abbreviation :: parse ( & buf) . expect ( "Should parse abbreviation" ) ;
0 commit comments