Skip to content

Commit 6964299

Browse files
committed
Remove unneeded allocation
`<E as serde::de::Error>::custom()` accepts any `T: Display`, not just `String`. Therefore it accepts `Arguments<'_>` too so we can use `format_args!()` instead of `format!()`. See #2187 (comment)
1 parent 56b0c96 commit 6964299

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lightning-invoice/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ impl<'de> Deserialize<'de> for Invoice {
17251725
fn deserialize<D>(deserializer: D) -> Result<Invoice, D::Error> where D: Deserializer<'de> {
17261726
let bolt11 = String::deserialize(deserializer)?
17271727
.parse::<Invoice>()
1728-
.map_err(|e| D::Error::custom(alloc::format!("{:?}", e)))?;
1728+
.map_err(|e| D::Error::custom(format_args!("{:?}", e)))?;
17291729

17301730
Ok(bolt11)
17311731
}

0 commit comments

Comments
 (0)