prost
prost copied to clipboard
feat: encode string and bytes slices
This PR adds the ability to encode &str and &[u8] using string::encode and bytes::encode. This is useful for users writing custom Message implementations who want to avoid unnecessary allocations.
Can you provide some motivation for this change
@morrisonlevi provided some context in his original PR: #978.
My use case is similar. I recently wrote a few custom Message implementations for types with some fields for which I can obtain a &str or &[u8] for free but not a String or Vec<u8> without allocating.
@caspermeijn, is there any chance you can look into this PR?