From 5d9247c34b08a0df3b6af896b88d052fcf3b9576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Wed, 2 Oct 2024 09:55:58 +0200 Subject: [PATCH] Add `?Sized` trait bound Fix #9 --- src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 48cce453..aa7495e7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,7 @@ pub use error::{Error, Result}; // pub use de::take_from_bytes; // kudos to postcard, this is much nicer than returning size -pub fn cbor_serialize<'a, T: serde::Serialize>( +pub fn cbor_serialize<'a, T: ?Sized + serde::Serialize>( object: &T, buffer: &'a mut [u8], ) -> Result<&'a [u8]> { @@ -33,7 +33,7 @@ pub fn cbor_serialize<'a, T: serde::Serialize>( } /// Append serialization of object to existing bytes, returning length of serialized object. -pub fn cbor_serialize_extending_bytes( +pub fn cbor_serialize_extending_bytes( object: &T, bytes: &mut Bytes, ) -> Result { @@ -46,7 +46,9 @@ pub fn cbor_serialize_extending_bytes( } /// Serialize object into newly allocated Bytes. -pub fn cbor_serialize_bytes(object: &T) -> Result> { +pub fn cbor_serialize_bytes( + object: &T, +) -> Result> { let mut data = Bytes::::new(); cbor_serialize_extending_bytes(object, &mut data)?; Ok(data)