From ec6ca6bf73559570fedc77a34b3fdd851bcc9509 Mon Sep 17 00:00:00 2001 From: Maciej Hirsz Date: Wed, 18 Mar 2020 13:34:38 +0100 Subject: [PATCH] Allow non-std Cow borrows --- serde/src/private/de.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/serde/src/private/de.rs b/serde/src/private/de.rs index 1c7fda3a..100673e2 100644 --- a/serde/src/private/de.rs +++ b/serde/src/private/de.rs @@ -53,9 +53,10 @@ where } #[cfg(any(feature = "std", feature = "alloc"))] -pub fn borrow_cow_str<'de: 'a, 'a, D>(deserializer: D) -> Result, D::Error> +pub fn borrow_cow_str<'de: 'a, 'a, D, R>(deserializer: D) -> Result where D: Deserializer<'de>, + R: From>, { struct CowStrVisitor; @@ -121,13 +122,14 @@ where } } - deserializer.deserialize_str(CowStrVisitor) + deserializer.deserialize_str(CowStrVisitor).map(From::from) } #[cfg(any(feature = "std", feature = "alloc"))] -pub fn borrow_cow_bytes<'de: 'a, 'a, D>(deserializer: D) -> Result, D::Error> +pub fn borrow_cow_bytes<'de: 'a, 'a, D, R>(deserializer: D) -> Result where D: Deserializer<'de>, + R: From>, { struct CowBytesVisitor; @@ -181,7 +183,7 @@ where } } - deserializer.deserialize_bytes(CowBytesVisitor) + deserializer.deserialize_bytes(CowBytesVisitor).map(From::from) } pub mod size_hint {