pub fn to_vec<T>(value: &T) -> Result<Vec<u8>, Error>Expand description
Encode the given value to a Vec using the default Encoding.
ยงExamples
use musli::{Decode, Encode};
use musli::packed;
#[derive(Decode, Encode)]
struct Person {
name: String,
age: u32,
}
let data = packed::to_vec(&Person {
name: "Aristotle".to_string(),
age: 61,
})?;
let person: Person = packed::from_slice(&data[..])?;
assert_eq!(person.name, "Aristotle");
assert_eq!(person.age, 61);