From 5a42ef28507e365ef7c29096bfe794e063791979 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 18 Oct 2024 11:54:45 +1100 Subject: [PATCH] Do not manually map IO error We have a `From` impl for IO error but we are manually mapping. Done in preparation for patching the `From` impl. --- bitcoin/src/consensus/encode.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bitcoin/src/consensus/encode.rs b/bitcoin/src/consensus/encode.rs index eb89dfe11..c64868ffe 100644 --- a/bitcoin/src/consensus/encode.rs +++ b/bitcoin/src/consensus/encode.rs @@ -160,7 +160,7 @@ macro_rules! decoder_fn { #[inline] fn $name(&mut self) -> core::result::Result<$val_type, Error> { let mut val = [0; $byte_len]; - self.read_exact(&mut val[..]).map_err(Error::Io)?; + self.read_exact(&mut val[..])?; Ok(<$val_type>::from_le_bytes(val)) } }; @@ -216,9 +216,7 @@ impl ReadExt for R { #[inline] fn read_bool(&mut self) -> Result { ReadExt::read_i8(self).map(|bit| bit != 0) } #[inline] - fn read_slice(&mut self, slice: &mut [u8]) -> Result<(), Error> { - self.read_exact(slice).map_err(Error::Io) - } + fn read_slice(&mut self, slice: &mut [u8]) -> Result<(), Error> { Ok(self.read_exact(slice)?) } #[inline] #[rustfmt::skip] // Formatter munges code comments below. fn read_compact_size(&mut self) -> Result {