From e9300529c540362fd8600aacd661019253d52dd7 Mon Sep 17 00:00:00 2001 From: NightMare-Vortex <93774088+NightMare-Vortex@users.noreply.github.com> Date: Wed, 20 Mar 2024 20:33:25 +0300 Subject: [PATCH] Fixed #707 implemented `Decode` and `BorrowDecode` for Rc --- .gitignore | 1 + src/features/impl_alloc.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 29c90d8f..2c32b890 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ *.swo .cargo .vscode +.idea rls*.log tarpaulin-report.html diff --git a/src/features/impl_alloc.rs b/src/features/impl_alloc.rs index f5186a76..3084eae0 100644 --- a/src/features/impl_alloc.rs +++ b/src/features/impl_alloc.rs @@ -451,6 +451,13 @@ where } } +impl Decode for Rc { + fn decode(decoder: &mut D) -> Result { + let decoded = String::decode(decoder)?; + Ok(decoded.into()) + } +} + impl<'de, T> BorrowDecode<'de> for Rc where T: BorrowDecode<'de>, @@ -461,6 +468,13 @@ where } } +impl<'de> BorrowDecode<'de> for Rc { + fn borrow_decode>(decoder: &mut D) -> Result { + let decoded = String::decode(decoder)?; + Ok(decoded.into()) + } +} + impl Encode for Rc where T: Encode + ?Sized,