From: Martin Habovstiak Date: Thu, 4 May 2023 09:21:04 +0000 (+0200) Subject: Remove unneeded allocation X-Git-Tag: v0.0.116-alpha1~53^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=6964299fc53920de68ee1e448301e6b4d82ce2ed;p=rust-lightning 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 --- 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) }