mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 05:31:02 +00:00
Allow non-std Cow borrows
This commit is contained in:
@@ -53,9 +53,10 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn borrow_cow_str<'de: 'a, 'a, D>(deserializer: D) -> Result<Cow<'a, str>, D::Error>
|
pub fn borrow_cow_str<'de: 'a, 'a, D, R>(deserializer: D) -> Result<R, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
|
R: From<Cow<'a, str>>,
|
||||||
{
|
{
|
||||||
struct CowStrVisitor;
|
struct CowStrVisitor;
|
||||||
|
|
||||||
@@ -121,13 +122,14 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializer.deserialize_str(CowStrVisitor)
|
deserializer.deserialize_str(CowStrVisitor).map(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn borrow_cow_bytes<'de: 'a, 'a, D>(deserializer: D) -> Result<Cow<'a, [u8]>, D::Error>
|
pub fn borrow_cow_bytes<'de: 'a, 'a, D, R>(deserializer: D) -> Result<R, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
|
R: From<Cow<'a, [u8]>>,
|
||||||
{
|
{
|
||||||
struct CowBytesVisitor;
|
struct CowBytesVisitor;
|
||||||
|
|
||||||
@@ -181,7 +183,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializer.deserialize_bytes(CowBytesVisitor)
|
deserializer.deserialize_bytes(CowBytesVisitor).map(From::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod size_hint {
|
pub mod size_hint {
|
||||||
|
|||||||
Reference in New Issue
Block a user