allow packing &str

This commit is contained in:
Sergey Chernov 2023-12-17 01:06:26 +03:00
parent ad32bbe26e
commit 94c91e788e
3 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "bipack_ru"
version = "0.4.3"
version = "0.4.4"
edition = "2021"
license = "Apache-2.0"
description = "binary size-effective format used in Divan smart contracts, wasm bindings, network protocols, etc."

View File

@ -269,7 +269,7 @@ mod tests {
use crate::de::from_bytes;
use crate::error::Result;
use crate::ser::{to_buffer, to_bytes};
use crate::tools::{to_dump};
use crate::tools::{to_dump, ToDump};
#[test]
fn test_ints() -> Result<()> {
@ -434,4 +434,11 @@ mod tests {
assert_eq!(7, packed.len());
}
#[test]
fn test_str() {
let src = "hello";
let x = to_bytes(src);
println!("{}", x.unwrap().to_dump());
}
}

View File

@ -11,7 +11,7 @@ pub struct Serializer<S: BipackSink> {
}
pub fn to_bytes<T>(value: &T) -> Result<Vec<u8>>
where T: Serialize,
where T: Serialize + ?Sized,
{
let mut serializer = Serializer { output: Vec::new() };
value.serialize(&mut serializer)?;