mirror of https://git.sr.ht/~stygianentity/bincode
Made the Cow Encode constraints more permissive (#524)
* Made the Cow Encode constraints more permissive * Made Decode more permissive for Cow
This commit is contained in:
parent
8eac3e9d4f
commit
a7fba80e23
|
|
@ -285,7 +285,7 @@ where
|
|||
|
||||
impl<'cow, T> Decode for Cow<'cow, T>
|
||||
where
|
||||
T: ToOwned,
|
||||
T: ToOwned + ?Sized,
|
||||
<T as ToOwned>::Owned: Decode,
|
||||
{
|
||||
fn decode<D: Decoder>(decoder: &mut D) -> Result<Self, DecodeError> {
|
||||
|
|
@ -296,7 +296,8 @@ where
|
|||
|
||||
impl<'cow, T> Encode for Cow<'cow, T>
|
||||
where
|
||||
T: Encode + Clone,
|
||||
T: ToOwned + ?Sized,
|
||||
for<'a> &'a T: Encode,
|
||||
{
|
||||
fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), EncodeError> {
|
||||
self.as_ref().encode(encoder)
|
||||
|
|
|
|||
|
|
@ -20,3 +20,6 @@ mod issue_498;
|
|||
|
||||
#[path = "issues/issue_500.rs"]
|
||||
mod issue_500;
|
||||
|
||||
#[path = "issues/issue_523.rs"]
|
||||
mod issue_523;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
#![cfg(all(feature = "derive", feature = "std"))]
|
||||
|
||||
extern crate std;
|
||||
|
||||
use bincode::{Decode, Encode};
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[derive(Clone, Encode, Decode)]
|
||||
pub struct Foo<'a>(Cow<'a, str>);
|
||||
Loading…
Reference in New Issue