prost icon indicating copy to clipboard operation
prost copied to clipboard

feat: encode string and bytes slices

Open guilload opened this issue 1 year ago • 3 comments

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.

guilload avatar Feb 09 '24 22:02 guilload

Can you provide some motivation for this change

LucioFranco avatar Feb 12 '24 20:02 LucioFranco

@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.

guilload avatar Feb 12 '24 20:02 guilload

@caspermeijn, is there any chance you can look into this PR?

guilload avatar Apr 19 '24 14:04 guilload