Fix borrowed Cow<'_, [u8]> deserializing as str.

This changes the deserialize implementation for a borrowed Cow<[u8]>
to specifically request a byte slice, rather than a borrowed string.

The old behavior breaks any program which relies on data being
deserialized the same way as it was serialized and uses Cow<[u8]>.
In serde_json, it just wouldn't deserialize. In bincode, it
deserialized normally unless the bytes were invalid UTF8.

Fixes https://github.com/TyOverby/bincode/issues/231.
This commit is contained in:
David Ross 2018-03-12 11:26:11 -07:00
parent 0d4d47c398
commit af9996aa9a

@ -188,7 +188,7 @@ where
}
}
deserializer.deserialize_str(CowBytesVisitor)
deserializer.deserialize_bytes(CowBytesVisitor)
}
pub mod size_hint {