@@ -270,24 +270,18 @@ impl TryInto<GetUtxosResponse> for JsonResponse {
270
270
type Error = std:: io:: Error ;
271
271
272
272
fn try_into ( self ) -> std:: io:: Result < GetUtxosResponse > {
273
- match self . 0 . as_object ( ) {
274
- None => Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , "expected an object" ) ) ,
275
- Some ( obj) => match obj. get ( "bitmap" ) {
276
- None => Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , "missing bitmap field" ) ) ,
277
- Some ( bitmap) => match bitmap. as_str ( ) {
278
- None => Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , "bitmap should be an str" ) ) ,
279
- Some ( bitmap_str) => {
280
- let mut hit_bitmap_nonempty = false ;
281
- for c in bitmap_str. chars ( ) {
282
- if c < '0' || c > '9' {
283
- return Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , "invalid byte" ) ) ;
284
- }
285
- if c > '0' { hit_bitmap_nonempty = true ; }
286
- }
287
- Ok ( GetUtxosResponse { hit_bitmap_nonempty } )
288
- }
273
+ let bitmap_str =
274
+ self . 0 . as_object ( ) . ok_or ( Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , "expected an object" ) ) ) ?
275
+ . get ( "bitmap" ) . ok_or ( Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , "missing bitmap field" ) ) ) ?
276
+ . as_str ( ) . ok_or ( Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , "bitmap should be an str" ) ) ) ?;
277
+ let mut hit_bitmap_nonempty = false ;
278
+ for c in bitmap_str. chars ( ) {
279
+ if c < '0' || c > '9' {
280
+ return Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , "invalid byte" ) ) ;
289
281
}
282
+ if c > '0' { hit_bitmap_nonempty = true ; }
290
283
}
284
+ Ok ( GetUtxosResponse { hit_bitmap_nonempty } )
291
285
}
292
286
}
293
287
}
0 commit comments