Skip to content

Commit

Permalink
Support serializing dynamically sized field
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Apr 7, 2019
1 parent 1752b18 commit 40f4a8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -76,7 +76,7 @@ pub use crate::bytebuf::ByteBuf;
/// ```
pub fn serialize<T, S>(bytes: &T, serializer: S) -> Result<S::Ok, S::Error>
where
T: Serialize,
T: ?Sized + Serialize,
S: Serializer,
{
Serialize::serialize(bytes, serializer)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_derive.rs
Expand Up @@ -28,3 +28,9 @@ struct Test<'a> {
#[serde(with = "serde_bytes")]
boxed_bytes: Box<Bytes>,
}

#[derive(Serialize)]
struct Dst {
#[serde(with = "serde_bytes")]
bytes: [u8],
}

0 comments on commit 40f4a8f

Please sign in to comment.