diff --git a/core/src/codec.rs b/core/src/codec.rs index 89f02db0..15b3c8a4 100644 --- a/core/src/codec.rs +++ b/core/src/codec.rs @@ -1,6 +1,6 @@ //! `Ipld` codecs. -use alloc::{format, string::String, vec::Vec}; -use core::convert::TryFrom; +use alloc::{string::String, vec::Vec}; +use core::{convert::TryFrom, fmt::Write as _}; use crate::cid::Cid; use crate::error::{Result, UnsupportedCodec}; @@ -85,7 +85,10 @@ where Ipld: Decode + Encode, { fn hex(bytes: &[u8]) -> String { - bytes.iter().map(|byte| format!("{:02x}", byte)).collect() + bytes.iter().fold(String::new(), |mut output, byte| { + let _ = write!(output, "{byte:02x}"); + output + }) } let mut bytes = Vec::new(); data.encode(c, &mut bytes).unwrap(); diff --git a/core/tests/serde_deserialize.rs b/core/tests/serde_deserialize.rs index 3e67ce2d..205ca60d 100644 --- a/core/tests/serde_deserialize.rs +++ b/core/tests/serde_deserialize.rs @@ -143,7 +143,7 @@ fn ipld_deserialize_link() { } #[test] -#[should_panic(expected = "assertion failed")] +#[should_panic] fn ipld_deserialize_link_not_as_bytes() { let cid = Cid::try_from("bafkreie74tgmnxqwojhtumgh5dzfj46gi4mynlfr7dmm7duwzyvnpw7h7m").unwrap(); let ipld = Ipld::Link(cid); diff --git a/dag-cbor/tests/serde_interop.rs b/dag-cbor/tests/serde_interop.rs index 40adaf52..5821f07a 100644 --- a/dag-cbor/tests/serde_interop.rs +++ b/dag-cbor/tests/serde_interop.rs @@ -41,8 +41,7 @@ impl Arbitrary for ValueArb { .into_iter() .map(|x| { let slf = Self(x); - let shrunk = slf.shrink().map(|x| x.0).collect::>(); - shrunk + slf.shrink().map(|x| x.0).collect::>() }) .map(Value::Array) .map(Self),