diff --git a/comms/core/src/message/mod.rs b/comms/core/src/message/mod.rs index 99172105fc..a68638d8f5 100644 --- a/comms/core/src/message/mod.rs +++ b/comms/core/src/message/mod.rs @@ -47,12 +47,7 @@ pub trait MessageExt: prost::Message { /// Encodes a message, allocating the buffer on the heap as necessary fn to_encoded_bytes(&self) -> Vec where Self: Sized { - let mut buf = Vec::with_capacity(self.encoded_len()); - self.encode(&mut buf).expect( - "prost::Message::encode documentation says it is infallible unless the buffer has insufficient capacity. \ - This buffer's capacity was set with encoded_len", - ); - buf + self.encode_to_vec() } /// Encodes a message into a BytesMut, allocating the buffer on the heap as necessary.