Skip to content

Commit 39f952e

Browse files
parser/bls: impl Display for BLSConfig
Signed-off-by: Johan-Liebert1 <[email protected]>
1 parent aa47694 commit 39f952e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

crates/lib/src/bls_config.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use anyhow::Result;
22
use serde::de::Error;
33
use serde::{Deserialize, Deserializer};
44
use std::collections::HashMap;
5+
use std::fmt::Display;
56

67
#[derive(Debug, Deserialize, Eq)]
78
pub(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

Comments
 (0)