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
@@ -191,11 +193,7 @@ impl DifferenceDisplay for RawDiffer {
191193 let mut result = table. to_string ( ) ;
192194
193195 if diffs. len ( ) > 10 {
194- let last_line_width = result
195- . lines ( )
196- . last ( )
197- . map ( |l| l. chars ( ) . count ( ) )
198- . unwrap_or ( 0 ) ;
196+ let last_line_width = result. lines ( ) . last ( ) . map_or ( 0 , |l| l. chars ( ) . count ( ) ) ;
199197 result. push_str ( & format ! (
200198 "\n {:>width$}" ,
201199 format!( "... {} more differences" , diffs. len( ) - 10 ) ,
@@ -226,7 +224,7 @@ impl DifferenceDisplay for RawDiffer {
226224 for ( i, chunk) in output. chunks ( 16 ) . enumerate ( ) {
227225 write ! ( file, "{:08x}: " , i * 16 ) ?;
228226 for byte in chunk {
229- write ! ( file, "{:02x} " , byte ) ?;
227+ write ! ( file, "{byte :02x} " ) ?;
230228 }
231229 writeln ! ( file) ?;
232230 }
@@ -255,7 +253,7 @@ impl NumericType for f32 {
255253 "F32"
256254 }
257255 fn format_value ( value : Self ) -> String {
258- format ! ( "{:.9}" , value )
256+ format ! ( "{value :.9}" )
259257 }
260258 fn can_have_relative_diff ( ) -> bool {
261259 true
@@ -280,7 +278,7 @@ impl NumericType for u32 {
280278 "U32"
281279 }
282280 fn format_value ( value : Self ) -> String {
283- format ! ( "{}" , value )
281+ format ! ( "{value}" )
284282 }
285283 fn can_have_relative_diff ( ) -> bool {
286284 true
@@ -379,7 +377,7 @@ impl<T: NumericType> DifferenceDisplay for NumericDiffer<T> {
379377 let abs_str = match & d. absolute_diff {
380378 DiffMagnitude :: Numeric ( val) => {
381379 if T :: can_have_relative_diff ( ) {
382- format ! ( "{:.3e}" , val )
380+ format ! ( "{val :.3e}" )
383381 } else {
384382 format ! ( "{}" , * val as u64 )
385383 }
@@ -431,11 +429,7 @@ impl<T: NumericType> DifferenceDisplay for NumericDiffer<T> {
431429 let mut result = table. to_string ( ) ;
432430
433431 if diffs. len ( ) > 10 {
434- let last_line_width = result
435- . lines ( )
436- . last ( )
437- . map ( |l| l. chars ( ) . count ( ) )
438- . unwrap_or ( 0 ) ;
432+ let last_line_width = result. lines ( ) . last ( ) . map_or ( 0 , |l| l. chars ( ) . count ( ) ) ;
439433 result. push_str ( & format ! (
440434 "\n {:>width$}" ,
441435 format!( "... {} more differences" , diffs. len( ) - 10 ) ,
@@ -482,9 +476,9 @@ impl From<OutputType> for Box<dyn OutputDiffer + Send + Sync> {
482476 match output_type {
483477 OutputType :: Raw => Box :: new ( RawDiffer ) ,
484478 OutputType :: F32 => Box :: new ( F32Differ :: default ( ) ) ,
485- OutputType :: F64 => todo ! ( "F64Differ not implemented yet" ) ,
479+ OutputType :: F64 => unimplemented ! ( "F64Differ not implemented yet" ) ,
486480 OutputType :: U32 => Box :: new ( U32Differ :: default ( ) ) ,
487- OutputType :: I32 => todo ! ( "I32Differ not implemented yet" ) ,
481+ OutputType :: I32 => unimplemented ! ( "I32Differ not implemented yet" ) ,
488482 }
489483 }
490484}
@@ -494,9 +488,9 @@ impl From<OutputType> for Box<dyn DifferenceDisplay + Send + Sync> {
494488 match output_type {
495489 OutputType :: Raw => Box :: new ( RawDiffer ) ,
496490 OutputType :: F32 => Box :: new ( F32Differ :: default ( ) ) ,
497- OutputType :: F64 => todo ! ( "F64Display not implemented yet" ) ,
491+ OutputType :: F64 => unimplemented ! ( "F64Differ not implemented yet" ) ,
498492 OutputType :: U32 => Box :: new ( U32Differ :: default ( ) ) ,
499- OutputType :: I32 => todo ! ( "I32Display not implemented yet" ) ,
493+ OutputType :: I32 => unimplemented ! ( "I32Differ not implemented yet" ) ,
500494 }
501495 }
502496}
@@ -533,11 +527,11 @@ mod tests {
533527 assert_eq ! ( diffs[ 0 ] . value2, "5" ) ;
534528 match & diffs[ 0 ] . absolute_diff {
535529 DiffMagnitude :: Numeric ( val) => assert_eq ! ( * val, 3.0 ) ,
536- _ => panic ! ( "Expected numeric difference" ) ,
530+ DiffMagnitude :: Incomparable => panic ! ( "Expected numeric difference" ) ,
537531 }
538532 match & diffs[ 0 ] . relative_diff {
539533 DiffMagnitude :: Numeric ( val) => assert_eq ! ( * val, 3.0 / 5.0 ) , // 3/5 = 0.6
540- _ => panic ! ( "Expected numeric relative diff for U32" ) ,
534+ DiffMagnitude :: Incomparable => panic ! ( "Expected numeric relative diff for U32" ) ,
541535 }
542536
543537 // Check second difference (index 3: 4 vs 7)
@@ -546,7 +540,7 @@ mod tests {
546540 assert_eq ! ( diffs[ 1 ] . value2, "7" ) ;
547541 match & diffs[ 1 ] . absolute_diff {
548542 DiffMagnitude :: Numeric ( val) => assert_eq ! ( * val, 3.0 ) ,
549- _ => panic ! ( "Expected numeric difference" ) ,
543+ DiffMagnitude :: Incomparable => panic ! ( "Expected numeric difference" ) ,
550544 }
551545 }
552546
@@ -665,12 +659,12 @@ mod tests {
665659
666660 match numeric {
667661 DiffMagnitude :: Numeric ( val) => assert_eq ! ( val, 42.0 ) ,
668- _ => panic ! ( "Expected numeric" ) ,
662+ DiffMagnitude :: Incomparable => panic ! ( "Expected numeric" ) ,
669663 }
670664
671665 match incomparable {
672666 DiffMagnitude :: Incomparable => { }
673- _ => panic ! ( "Expected incomparable" ) ,
667+ DiffMagnitude :: Numeric ( _ ) => panic ! ( "Expected incomparable" ) ,
674668 }
675669 }
676670}
0 commit comments