1+ #![ allow( clippy:: unimplemented) ]
2+
13use difftest:: config:: OutputType ;
24use std:: marker:: PhantomData ;
35
@@ -67,16 +69,16 @@ impl OutputDiffer for RawDiffer {
6769 ( Some ( & b1) , Some ( & b2) ) if b1 != b2 => {
6870 differences. push ( Difference {
6971 index : i,
70- value1 : format ! ( "{}" , b1 ) ,
71- value2 : format ! ( "{}" , b2 ) ,
72+ value1 : format ! ( "{b1}" ) ,
73+ value2 : format ! ( "{b2}" ) ,
7274 absolute_diff : DiffMagnitude :: Incomparable ,
7375 relative_diff : DiffMagnitude :: Incomparable ,
7476 } ) ;
7577 }
7678 ( Some ( & b1) , None ) => {
7779 differences. push ( Difference {
7880 index : i,
79- value1 : format ! ( "{}" , b1 ) ,
81+ value1 : format ! ( "{b1}" ) ,
8082 value2 : "" . to_string ( ) ,
8183 absolute_diff : DiffMagnitude :: Incomparable ,
8284 relative_diff : DiffMagnitude :: Incomparable ,
@@ -86,7 +88,7 @@ impl OutputDiffer for RawDiffer {
8688 differences. push ( Difference {
8789 index : i,
8890 value1 : "" . to_string ( ) ,
89- value2 : format ! ( "{}" , b2 ) ,
91+ value2 : format ! ( "{b2}" ) ,
9092 absolute_diff : DiffMagnitude :: Incomparable ,
9193 relative_diff : DiffMagnitude :: Incomparable ,
9294 } ) ;
@@ -129,8 +131,8 @@ impl DifferenceDisplay for RawDiffer {
129131 } ;
130132 (
131133 format ! ( "{:>3}" , format!( "{:02x}" , byte) ) ,
132- format ! ( "{:3}" , byte ) ,
133- format ! ( "{:^5}" , ascii ) ,
134+ format ! ( "{byte :3}" ) ,
135+ format ! ( "{ascii :^5}" ) ,
134136 )
135137 } ;
136138
@@ -151,8 +153,8 @@ impl DifferenceDisplay for RawDiffer {
151153 } ;
152154 (
153155 format ! ( "{:>3}" , format!( "{:02x}" , byte) ) ,
154- format ! ( "{:3}" , byte ) ,
155- format ! ( "{:^5}" , ascii ) ,
156+ format ! ( "{byte :3}" ) ,
157+ format ! ( "{ascii :^5}" ) ,
156158 )
157159 } ;
158160
@@ -194,8 +196,7 @@ impl DifferenceDisplay for RawDiffer {
194196 let last_line_width = result
195197 . lines ( )
196198 . last ( )
197- . map ( |l| l. chars ( ) . count ( ) )
198- . unwrap_or ( 0 ) ;
199+ . map_or ( 0 , |l| l. chars ( ) . count ( ) ) ;
199200 result. push_str ( & format ! (
200201 "\n {:>width$}" ,
201202 format!( "... {} more differences" , diffs. len( ) - 10 ) ,
@@ -226,7 +227,7 @@ impl DifferenceDisplay for RawDiffer {
226227 for ( i, chunk) in output. chunks ( 16 ) . enumerate ( ) {
227228 write ! ( file, "{:08x}: " , i * 16 ) ?;
228229 for byte in chunk {
229- write ! ( file, "{:02x} " , byte ) ?;
230+ write ! ( file, "{byte :02x} " ) ?;
230231 }
231232 writeln ! ( file) ?;
232233 }
@@ -255,7 +256,7 @@ impl NumericType for f32 {
255256 "F32"
256257 }
257258 fn format_value ( value : Self ) -> String {
258- format ! ( "{:.9}" , value )
259+ format ! ( "{value :.9}" )
259260 }
260261 fn can_have_relative_diff ( ) -> bool {
261262 true
@@ -280,7 +281,7 @@ impl NumericType for u32 {
280281 "U32"
281282 }
282283 fn format_value ( value : Self ) -> String {
283- format ! ( "{}" , value )
284+ format ! ( "{value}" )
284285 }
285286 fn can_have_relative_diff ( ) -> bool {
286287 true
@@ -379,7 +380,7 @@ impl<T: NumericType> DifferenceDisplay for NumericDiffer<T> {
379380 let abs_str = match & d. absolute_diff {
380381 DiffMagnitude :: Numeric ( val) => {
381382 if T :: can_have_relative_diff ( ) {
382- format ! ( "{:.3e}" , val )
383+ format ! ( "{val :.3e}" )
383384 } else {
384385 format ! ( "{}" , * val as u64 )
385386 }
@@ -434,8 +435,7 @@ impl<T: NumericType> DifferenceDisplay for NumericDiffer<T> {
434435 let last_line_width = result
435436 . lines ( )
436437 . last ( )
437- . map ( |l| l. chars ( ) . count ( ) )
438- . unwrap_or ( 0 ) ;
438+ . map_or ( 0 , |l| l. chars ( ) . count ( ) ) ;
439439 result. push_str ( & format ! (
440440 "\n {:>width$}" ,
441441 format!( "... {} more differences" , diffs. len( ) - 10 ) ,
@@ -482,9 +482,9 @@ impl From<OutputType> for Box<dyn OutputDiffer + Send + Sync> {
482482 match output_type {
483483 OutputType :: Raw => Box :: new ( RawDiffer ) ,
484484 OutputType :: F32 => Box :: new ( F32Differ :: default ( ) ) ,
485- OutputType :: F64 => todo ! ( "F64Differ not implemented yet" ) ,
485+ OutputType :: F64 => unimplemented ! ( "F64Differ not implemented yet" ) ,
486486 OutputType :: U32 => Box :: new ( U32Differ :: default ( ) ) ,
487- OutputType :: I32 => todo ! ( "I32Differ not implemented yet" ) ,
487+ OutputType :: I32 => unimplemented ! ( "I32Differ not implemented yet" ) ,
488488 }
489489 }
490490}
@@ -494,9 +494,9 @@ impl From<OutputType> for Box<dyn DifferenceDisplay + Send + Sync> {
494494 match output_type {
495495 OutputType :: Raw => Box :: new ( RawDiffer ) ,
496496 OutputType :: F32 => Box :: new ( F32Differ :: default ( ) ) ,
497- OutputType :: F64 => todo ! ( "F64Display not implemented yet" ) ,
497+ OutputType :: F64 => unimplemented ! ( "F64Differ not implemented yet" ) ,
498498 OutputType :: U32 => Box :: new ( U32Differ :: default ( ) ) ,
499- OutputType :: I32 => todo ! ( "I32Display not implemented yet" ) ,
499+ OutputType :: I32 => unimplemented ! ( "I32Differ not implemented yet" ) ,
500500 }
501501 }
502502}
@@ -533,11 +533,11 @@ mod tests {
533533 assert_eq ! ( diffs[ 0 ] . value2, "5" ) ;
534534 match & diffs[ 0 ] . absolute_diff {
535535 DiffMagnitude :: Numeric ( val) => assert_eq ! ( * val, 3.0 ) ,
536- _ => panic ! ( "Expected numeric difference" ) ,
536+ DiffMagnitude :: Incomparable => panic ! ( "Expected numeric difference" ) ,
537537 }
538538 match & diffs[ 0 ] . relative_diff {
539539 DiffMagnitude :: Numeric ( val) => assert_eq ! ( * val, 3.0 / 5.0 ) , // 3/5 = 0.6
540- _ => panic ! ( "Expected numeric relative diff for U32" ) ,
540+ DiffMagnitude :: Incomparable => panic ! ( "Expected numeric relative diff for U32" ) ,
541541 }
542542
543543 // Check second difference (index 3: 4 vs 7)
@@ -546,7 +546,7 @@ mod tests {
546546 assert_eq ! ( diffs[ 1 ] . value2, "7" ) ;
547547 match & diffs[ 1 ] . absolute_diff {
548548 DiffMagnitude :: Numeric ( val) => assert_eq ! ( * val, 3.0 ) ,
549- _ => panic ! ( "Expected numeric difference" ) ,
549+ DiffMagnitude :: Incomparable => panic ! ( "Expected numeric difference" ) ,
550550 }
551551 }
552552
@@ -665,12 +665,12 @@ mod tests {
665665
666666 match numeric {
667667 DiffMagnitude :: Numeric ( val) => assert_eq ! ( val, 42.0 ) ,
668- _ => panic ! ( "Expected numeric" ) ,
668+ DiffMagnitude :: Incomparable => panic ! ( "Expected numeric" ) ,
669669 }
670670
671671 match incomparable {
672672 DiffMagnitude :: Incomparable => { }
673- _ => panic ! ( "Expected incomparable" ) ,
673+ DiffMagnitude :: Numeric ( _ ) => panic ! ( "Expected incomparable" ) ,
674674 }
675675 }
676676}
0 commit comments