@@ -262,13 +262,13 @@ impl std::fmt::Display for VerifyResult {
262
262
f,
263
263
"\n {}{}{}\n {}{}{}{}{}{}\n " ,
264
264
& self . status. status_msg. green( ) . bold( ) ,
265
- " Runtime: ". dimmed( ) ,
265
+ & " Runtime: ". before_spaces ( 7 ) . dimmed( ) ,
266
266
& self . status. status_runtime. dimmed( ) ,
267
- "\n Your input: " ,
268
- & self . data_input. replace( "\n " , "↩" ) ,
269
- "\n Output: " ,
267
+ & "\n Your input:" . after_spaces ( 4 ) ,
268
+ & self . data_input. replace( "\n " , "↩" ) ,
269
+ & "\n Output:" . after_spaces ( 8 ) ,
270
270
ca,
271
- "\n Expected: " ,
271
+ & "\n Expected:" . after_spaces ( 6 ) ,
272
272
eca,
273
273
) ?
274
274
} else if !self . submit . compare_result . is_empty ( ) {
@@ -334,11 +334,11 @@ impl std::fmt::Display for VerifyResult {
334
334
"Wrong Answer" . red( ) . bold( ) ,
335
335
" Runtime: " . dimmed( ) ,
336
336
& self . status. status_runtime. dimmed( ) ,
337
- "\n Your input: " ,
338
- & self . data_input. replace( "\n " , "↩" ) ,
339
- "\n Output: " ,
337
+ & "\n Your input:" . after_spaces ( 4 ) ,
338
+ & self . data_input. replace( "\n " , "↩" ) ,
339
+ & "\n Output:" . after_spaces ( 8 ) ,
340
340
ca,
341
- "\n Expected: " ,
341
+ & "\n Expected:" . after_spaces ( 6 ) ,
342
342
eca,
343
343
) ?
344
344
}
@@ -348,15 +348,15 @@ impl std::fmt::Display for VerifyResult {
348
348
f,
349
349
"\n {}\n \n {}{}\n {}{}\n {}{}\n " ,
350
350
& self . status. status_msg. red( ) . bold( ) ,
351
- "Cases passed: " . green( ) ,
351
+ "Cases passed:" . after_spaces ( 2 ) . green( ) ,
352
352
& self
353
353
. analyse
354
354
. total_correct
355
355
. as_ref( )
356
356
. unwrap_or( & Number :: from( 0 ) )
357
357
. to_string( )
358
358
. green( ) ,
359
- "Total cases: " . yellow( ) ,
359
+ & "Total cases:" . after_spaces ( 3 ) . yellow( ) ,
360
360
& self
361
361
. analyse
362
362
. total_testcases
@@ -365,8 +365,8 @@ impl std::fmt::Display for VerifyResult {
365
365
. to_string( )
366
366
. bold( )
367
367
. yellow( ) ,
368
- "Last case: " . dimmed( ) ,
369
- & self . submit. last_testcase. replace( "\n " , "↩" ) . dimmed( )
368
+ & "Last case:" . after_spaces ( 5 ) . dimmed( ) ,
369
+ & self . submit. last_testcase. replace( "\n " , "↩" ) . dimmed( )
370
370
) ?,
371
371
// Output Timeout Exceeded
372
372
//
@@ -404,8 +404,8 @@ impl std::fmt::Display for VerifyResult {
404
404
write ! (
405
405
f,
406
406
"{}{}" ,
407
- "Stdout: " . purple( ) ,
408
- & self . code_output. join( "\n " )
407
+ & "Stdout:" . after_spaces ( 8 ) . purple( ) ,
408
+ & self . code_output. join( & "\n " . after_spaces ( 15 ) )
409
409
)
410
410
} else {
411
411
write ! ( f, "" )
@@ -416,8 +416,8 @@ impl std::fmt::Display for VerifyResult {
416
416
write ! (
417
417
f,
418
418
"{}{}" ,
419
- "Stdout: " . purple( ) ,
420
- & self . std_output. replace( "\n " , "\n " )
419
+ & "Stdout:" . after_spaces ( 8 ) . purple( ) ,
420
+ & self . std_output. replace( "\n " , & "\n " . after_spaces ( 15 ) )
421
421
)
422
422
} else {
423
423
write ! ( f, "" )
@@ -428,7 +428,6 @@ impl std::fmt::Display for VerifyResult {
428
428
}
429
429
430
430
use verify:: * ;
431
-
432
431
mod verify {
433
432
use super :: super :: parser:: ssr;
434
433
use serde:: Deserialize ;
@@ -508,3 +507,25 @@ mod verify {
508
507
pub expected_code_answer : Vec < String > ,
509
508
}
510
509
}
510
+
511
+ /// Formatter for str
512
+ trait Formatter {
513
+ fn after_spaces < ' f > ( & self , spaces : usize ) -> String ;
514
+ fn before_spaces < ' f > ( & self , spaces : usize ) -> String ;
515
+ }
516
+
517
+ impl Formatter for str {
518
+ fn after_spaces < ' f > ( & self , spaces : usize ) -> String {
519
+ let mut r = String :: new ( ) ;
520
+ r. push_str ( self ) ;
521
+ r. push_str ( & " " . repeat ( spaces) ) ;
522
+ r
523
+ }
524
+
525
+ fn before_spaces < ' f > ( & self , spaces : usize ) -> String {
526
+ let mut r = String :: new ( ) ;
527
+ r. push_str ( & " " . repeat ( spaces) ) ;
528
+ r. push_str ( self ) ;
529
+ r
530
+ }
531
+ }
0 commit comments