Skip to content

Commit bef56cb

Browse files
committed
fmt peer_msg using write_fmt, use alloc::string::String, some cleanup
1 parent f06b59d commit bef56cb

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lightning/src/util/events.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ impl core::fmt::Display for ClosureReason {
176176
f.write_str("Channel closed because ")?;
177177
match self {
178178
ClosureReason::CounterpartyForceClosed { peer_msg } => {
179-
f.write_str("counterparty force-closed with message ")?;
180-
f.write_str(&format!("{}", peer_msg))
179+
f.write_fmt(format_args!("counterparty force-closed with message: {}", peer_msg))
181180
},
182181
ClosureReason::HolderForceClosed => f.write_str("user manually force-closed the channel"),
183182
ClosureReason::CooperativeClosure => f.write_str("the channel was cooperatively closed"),

lightning/src/util/string.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
//! Utilities for strings.
1111
12+
use alloc::string::String;
1213
use core::fmt;
13-
use crate::util::ser::{Writeable, Writer, Readable};
1414
use crate::io::{self, Read};
1515
use crate::ln::msgs;
16+
use crate::util::ser::{Writeable, Writer, Readable};
1617

1718
/// A string that displays only printable characters, replacing control characters with
1819
/// [`core::char::REPLACEMENT_CHARACTER`].
@@ -62,7 +63,7 @@ impl Readable for SanitizedString {
6263
}
6364

6465
impl fmt::Display for SanitizedString {
65-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
66+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6667
PrintableString(&self.0).fmt(f)
67-
}
68-
}
68+
}
69+
}

0 commit comments

Comments
 (0)