This can be handy to avoid an heap allocation, because it is possible to use the result of the const fn to allocate an array of the right size.
EDIT: I changed a bit the initial proposal in order to make it actually easier to use in const context. Previously encoded_len took a slice (like in the trait), now it takes an usize representing the number of bytes to encode.
This can be handy to avoid an heap allocation, because it is possible to use the result of the const fn to allocate an array of the right size.
EDIT: I changed a bit the initial proposal in order to make it actually easier to use in const context. Previously
encoded_len
took a slice (like in the trait), now it takes anusize
representing the number of bytes to encode.