diff --git a/src/error.rs b/src/error.rs index 148ddf84..8aa0db92 100644 --- a/src/error.rs +++ b/src/error.rs @@ -197,12 +197,14 @@ pub enum OutOfMemory { Alloc(AllocError), } +#[cfg(feature = "alloc")] impl From for DecodeError { fn from(e: TryReserveError) -> Self { Self::OutOfMemory(OutOfMemory::TryReserve(e)) } } +#[cfg(feature = "alloc")] impl From for EncodeError { fn from(e: TryReserveError) -> Self { Self::OutOfMemory(OutOfMemory::TryReserve(e)) diff --git a/src/features/serde/de_borrowed.rs b/src/features/serde/de_borrowed.rs index d70d2c3e..fbda60ef 100644 --- a/src/features/serde/de_borrowed.rs +++ b/src/features/serde/de_borrowed.rs @@ -403,7 +403,7 @@ impl<'de, 'a, DE: BorrowDecoder<'de>> EnumAccess<'de> for SerdeDecoder<'a, 'de, V: DeserializeSeed<'de>, { let idx = u32::decode(&mut self.de)?; - let val = seed.deserialize(idx.into_deserializer())?; + let val = seed.deserialize(serde::de::value::U32Deserializer::::new(idx))?; Ok((val, self)) } } diff --git a/src/features/serde/de_owned.rs b/src/features/serde/de_owned.rs index 9a3ba780..d9397b68 100644 --- a/src/features/serde/de_owned.rs +++ b/src/features/serde/de_owned.rs @@ -449,7 +449,7 @@ impl<'de, 'a, DE: Decoder> EnumAccess<'de> for SerdeDecoder<'a, DE> { V: DeserializeSeed<'de>, { let idx = u32::decode(&mut self.de)?; - let val = seed.deserialize(idx.into_deserializer())?; + let val = seed.deserialize(serde::de::value::U32Deserializer::::new(idx))?; Ok((val, self)) } } diff --git a/src/features/serde/mod.rs b/src/features/serde/mod.rs index fc3952fb..f418380e 100644 --- a/src/features/serde/mod.rs +++ b/src/features/serde/mod.rs @@ -142,10 +142,9 @@ pub enum EncodeError { CustomError, } -#[allow(clippy::from_over_into)] -impl Into for EncodeError { - fn into(self) -> crate::error::EncodeError { - crate::error::EncodeError::Serde(self) +impl From for crate::error::EncodeError { + fn from(val: EncodeError) -> Self { + crate::error::EncodeError::Serde(val) } } diff --git a/src/features/serde/ser.rs b/src/features/serde/ser.rs index feede35c..7c8e62b9 100644 --- a/src/features/serde/ser.rs +++ b/src/features/serde/ser.rs @@ -224,7 +224,7 @@ where } fn serialize_seq(mut self, len: Option) -> Result { - let len = len.ok_or_else(|| SerdeEncodeError::SequenceMustHaveLength.into())?; + let len = len.ok_or(EncodeError::Serde(SerdeEncodeError::SequenceMustHaveLength))?; len.encode(&mut self.enc)?; Ok(Compound { enc: self.enc }) } @@ -253,7 +253,7 @@ where } fn serialize_map(mut self, len: Option) -> Result { - let len = len.ok_or_else(|| SerdeEncodeError::SequenceMustHaveLength.into())?; + let len = len.ok_or(EncodeError::Serde(SerdeEncodeError::SequenceMustHaveLength))?; len.encode(&mut self.enc)?; Ok(Compound { enc: self.enc }) }