@@ -2,6 +2,7 @@ use anyhow::Result;
2
2
use serde:: de:: Error ;
3
3
use serde:: { Deserialize , Deserializer } ;
4
4
use std:: collections:: HashMap ;
5
+ use std:: fmt:: Display ;
5
6
6
7
#[ derive( Debug , Deserialize , Eq ) ]
7
8
pub ( crate ) struct BLSConfig {
@@ -34,24 +35,22 @@ impl Ord for BLSConfig {
34
35
}
35
36
}
36
37
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 {
41
40
if let Some ( title) = & self . title {
42
- out += & format ! ( "title {}\n " , title) ;
41
+ writeln ! ( f , "title {}" , title) ? ;
43
42
}
44
43
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) ? ;
49
48
50
49
for ( key, value) in & self . extra {
51
- out += & format ! ( "{} {}\n " , key, value) ;
50
+ writeln ! ( f , "{} {}" , key, value) ? ;
52
51
}
53
52
54
- out
53
+ Ok ( ( ) )
55
54
}
56
55
}
57
56
0 commit comments