@@ -33,9 +33,9 @@ impl Parse for BitRange {
3333 let text = range
3434 . text
3535 . as_ref ( )
36- . ok_or ( SVDErrorKind :: Other ( format ! ( "text missing" ) ) ) ?; // TODO: Make into a proper error, text empty or something similar
37- // TODO: If the `InvalidBitRange` enum was an error we could context into here somehow so that
38- // the output would be similar to the parse error
36+ . ok_or_else ( || SVDErrorKind :: Other ( "text missing" . to_string ( ) ) ) ?; // TODO: Make into a proper error, text empty or something similar
37+ // TODO: If the `InvalidBitRange` enum was an error we could context into here somehow so that
38+ // the output would be similar to the parse error
3939 if !text. starts_with ( '[' ) {
4040 return Err (
4141 SVDErrorKind :: InvalidBitRange ( tree. clone ( ) , InvalidBitRange :: Syntax ) . into ( ) ,
@@ -51,21 +51,19 @@ impl Parse for BitRange {
5151 (
5252 parts
5353 . next ( )
54- . ok_or ( SVDErrorKind :: InvalidBitRange (
55- tree. clone ( ) ,
56- InvalidBitRange :: Syntax ,
57- ) ) ?
54+ . ok_or_else ( || {
55+ SVDErrorKind :: InvalidBitRange ( tree. clone ( ) , InvalidBitRange :: Syntax )
56+ } ) ?
5857 . parse :: < u32 > ( )
5958 . context ( SVDErrorKind :: InvalidBitRange (
6059 tree. clone ( ) ,
6160 InvalidBitRange :: ParseError ,
6261 ) ) ?,
6362 parts
6463 . next ( )
65- . ok_or ( SVDErrorKind :: InvalidBitRange (
66- tree. clone ( ) ,
67- InvalidBitRange :: Syntax ,
68- ) ) ?
64+ . ok_or_else ( || {
65+ SVDErrorKind :: InvalidBitRange ( tree. clone ( ) , InvalidBitRange :: Syntax )
66+ } ) ?
6967 . parse :: < u32 > ( )
7068 . context ( SVDErrorKind :: InvalidBitRange (
7169 tree. clone ( ) ,
@@ -116,7 +114,7 @@ impl Parse for BitRange {
116114 Ok ( BitRange {
117115 offset : start,
118116 width : end - start + 1 ,
119- range_type : range_type ,
117+ range_type,
120118 } )
121119 }
122120}
0 commit comments