From 6964299fc53920de68ee1e448301e6b4d82ce2ed Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Thu, 4 May 2023 11:21:04 +0200 Subject: [PATCH] Remove unneeded allocation `::custom()` accepts any `T: Display`, not just `String`. Therefore it accepts `Arguments<'_>` too so we can use `format_args!()` instead of `format!()`. See https://github.com/lightningdevkit/rust-lightning/pull/2187#discussion_r1168781355 --- lightning-invoice/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index 101051b5e..f53c8953b 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -1725,7 +1725,7 @@ impl<'de> Deserialize<'de> for Invoice { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de> { let bolt11 = String::deserialize(deserializer)? .parse::() - .map_err(|e| D::Error::custom(alloc::format!("{:?}", e)))?; + .map_err(|e| D::Error::custom(format_args!("{:?}", e)))?; Ok(bolt11) } -- 2.39.5