66#![ cfg( feature = "serde" ) ]
77
88use bincode:: serialize;
9- use bitcoin_units:: { amount, fee_rate, Amount , BlockHeight , BlockHeightInterval , BlockTime , FeeRate , Sequence , SignedAmount , Weight } ;
10- use serde:: { Deserialize , Serialize } ;
11- use bitcoin_units:: absolute:: { LockTime as AbsoluteLockTime , Height , MedianTimePast } ;
9+ use bitcoin_units:: absolute:: { Height , LockTime as AbsoluteLockTime , MedianTimePast } ;
1210use bitcoin_units:: relative:: { LockTime as RelativeLockTime , NumberOf512Seconds , NumberOfBlocks } ;
11+ use bitcoin_units:: {
12+ amount, fee_rate, Amount , BlockHeight , BlockHeightInterval , BlockTime , FeeRate , Sequence ,
13+ SignedAmount , Weight ,
14+ } ;
15+ use serde:: { Deserialize , Serialize } ;
1316
1417/// A struct that includes all the types that implement or support `serde` traits.
1518#[ derive( Debug , Serialize , Deserialize ) ]
@@ -300,14 +303,10 @@ fn serde_amount_as_str_opt() {
300303}
301304
302305#[ track_caller]
303- fn fee_rate_vb ( vb : u32 ) -> FeeRate {
304- FeeRate :: from_sat_per_vb ( vb)
305- }
306+ fn fee_rate_vb ( vb : u32 ) -> FeeRate { FeeRate :: from_sat_per_vb ( vb) }
306307
307308#[ track_caller]
308- fn fee_rate_kwu ( vb : u32 ) -> FeeRate {
309- FeeRate :: from_sat_per_kwu ( vb)
310- }
309+ fn fee_rate_kwu ( vb : u32 ) -> FeeRate { FeeRate :: from_sat_per_kwu ( vb) }
311310
312311#[ test]
313312#[ cfg( feature = "serde" ) ]
@@ -502,15 +501,12 @@ fn serde_fee_rate_as_sat_per_vb_ceil_opt() {
502501#[ cfg( feature = "serde" ) ]
503502#[ cfg( feature = "alloc" ) ]
504503fn serde_as_block_height ( ) {
505-
506504 #[ derive( Serialize , Deserialize , PartialEq , Debug ) ]
507505 struct T {
508- pub block_height : BlockHeight
506+ pub block_height : BlockHeight ,
509507 }
510508
511- let orig = T {
512- block_height : BlockHeight :: from_u32 ( 123_456_789 )
513- } ;
509+ let orig = T { block_height : BlockHeight :: from_u32 ( 123_456_789 ) } ;
514510
515511 let json = "{\" block_height\" : 123456789}" ;
516512
@@ -525,15 +521,12 @@ fn serde_as_block_height() {
525521#[ cfg( feature = "serde" ) ]
526522#[ cfg( feature = "alloc" ) ]
527523fn serde_as_block_interval ( ) {
528-
529524 #[ derive( Serialize , Deserialize , PartialEq , Debug ) ]
530525 struct T {
531- pub block_interval : BlockHeightInterval
526+ pub block_interval : BlockHeightInterval ,
532527 }
533528
534- let orig = T {
535- block_interval : BlockHeightInterval :: from_u32 ( 144 )
536- } ;
529+ let orig = T { block_interval : BlockHeightInterval :: from_u32 ( 144 ) } ;
537530
538531 let json = "{\" block_interval\" : 144}" ;
539532
@@ -548,15 +541,12 @@ fn serde_as_block_interval() {
548541#[ cfg( feature = "serde" ) ]
549542#[ cfg( feature = "alloc" ) ]
550543fn serde_as_weight ( ) {
551-
552544 #[ derive( Serialize , Deserialize , PartialEq , Debug ) ]
553545 struct T {
554- pub weight : Weight
546+ pub weight : Weight ,
555547 }
556548
557- let orig = T {
558- weight : Weight :: from_wu ( 25 )
559- } ;
549+ let orig = T { weight : Weight :: from_wu ( 25 ) } ;
560550
561551 let json = "{\" weight\" : 25}" ;
562552
@@ -571,15 +561,12 @@ fn serde_as_weight() {
571561#[ cfg( feature = "serde" ) ]
572562#[ cfg( feature = "alloc" ) ]
573563fn serde_as_block_time ( ) {
574-
575564 #[ derive( Serialize , Deserialize , PartialEq , Debug ) ]
576565 struct T {
577- pub block_time : BlockTime
566+ pub block_time : BlockTime ,
578567 }
579568
580- let orig = T {
581- block_time : BlockTime :: from_u32 ( 123_456_789 )
582- } ;
569+ let orig = T { block_time : BlockTime :: from_u32 ( 123_456_789 ) } ;
583570
584571 let json = "{\" block_time\" : 123456789}" ;
585572
@@ -594,15 +581,12 @@ fn serde_as_block_time() {
594581#[ cfg( feature = "serde" ) ]
595582#[ cfg( feature = "alloc" ) ]
596583fn serde_as_sequence_from_hex ( ) {
597-
598584 #[ derive( Serialize , Deserialize , PartialEq , Debug ) ]
599585 struct T {
600- pub sequence : Sequence
586+ pub sequence : Sequence ,
601587 }
602588
603- let orig = T {
604- sequence : Sequence :: from_hex ( "0x0040ffff" ) . unwrap ( )
605- } ;
589+ let orig = T { sequence : Sequence :: from_hex ( "0x0040ffff" ) . unwrap ( ) } ;
606590
607591 let json = "{\" sequence\" : 4259839}" ;
608592
@@ -617,7 +601,6 @@ fn serde_as_sequence_from_hex() {
617601#[ cfg( feature = "serde" ) ]
618602#[ cfg( feature = "alloc" ) ]
619603fn serde_as_locktime_from_blocks ( ) {
620-
621604 #[ derive( Serialize , Deserialize , PartialEq , Debug ) ]
622605 struct T {
623606 pub a_lt : AbsoluteLockTime ,
@@ -642,7 +625,6 @@ fn serde_as_locktime_from_blocks() {
642625#[ cfg( feature = "serde" ) ]
643626#[ cfg( feature = "alloc" ) ]
644627fn serde_as_locktime_from_time ( ) {
645-
646628 #[ derive( Serialize , Deserialize , PartialEq , Debug ) ]
647629 struct T {
648630 pub a_lt : AbsoluteLockTime ,
0 commit comments