@@ -2,6 +2,7 @@ use anyhow::Result;
22use serde:: de:: Error ;
33use serde:: { Deserialize , Deserializer } ;
44use std:: collections:: HashMap ;
5+ use std:: fmt:: Display ;
56
67#[ derive( Debug , Deserialize , Eq ) ]
78pub ( crate ) struct BLSConfig {
@@ -34,24 +35,22 @@ impl Ord for BLSConfig {
3435 }
3536}
3637
37- impl BLSConfig {
38- pub ( crate ) fn to_string ( & self ) -> String {
39- let mut out = String :: new ( ) ;
40-
38+ impl Display for BLSConfig {
39+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
4140 if let Some ( title) = & self . title {
42- out += & format ! ( "title {}\n " , title) ;
41+ writeln ! ( f , "title {}" , title) ? ;
4342 }
4443
45- out += & format ! ( "version {}\n " , self . version) ;
46- out += & format ! ( "linux {}\n " , self . linux) ;
47- out += & format ! ( "initrd {}\n " , self . initrd) ;
48- out += & format ! ( "options {}\n " , self . options) ;
44+ writeln ! ( f , "version {}" , self . version) ? ;
45+ writeln ! ( f , "linux {}" , self . linux) ? ;
46+ writeln ! ( f , "initrd {}" , self . initrd) ? ;
47+ writeln ! ( f , "options {}" , self . options) ? ;
4948
5049 for ( key, value) in & self . extra {
51- out += & format ! ( "{} {}\n " , key, value) ;
50+ writeln ! ( f , "{} {}" , key, value) ? ;
5251 }
5352
54- out
53+ Ok ( ( ) )
5554 }
5655}
5756
0 commit comments