"I'd expect this to work, but..." <- > <@jsizeland:matrix.org> I'd expect this to work, but it errors on the Vec being empty > ```rust > #![no_std] > > #[cfg(test)] > mod tests { > > use heapless::Vec; > use bincode::{config, Decode, Encode}; > > #[derive(Encode, Decode, PartialEq, Debug)] > struct Entity { > x: u32, > y: u32, > } > > #[test] > fn encode_bytes() { > let config = config::standard(); > let mut dst: Vec = Default::default(); > let val = Entity { x: 1, y: 2 }; > > bincode::encode_into_slice(val, &mut dst, config).unwrap(); > assert_eq!(dst.len(), 8); > } > } > ``` You could use an array of zeroes, and write to that, or you could pre-fill the heapless Vec with zeros, and then trim it once the bincode write is done. Or you could make a wrapper type and implement bincode::enc::write::Writer on the wrapper type and have the wrapper write to an inner heapless::Vec.