KokaKiwi / rust-hex

A basic crate to encode values to hexadecimal representation. Originally extracted from rustc-serialize.
https://crates.io/crates/hex
Apache License 2.0
203 stars 57 forks source link

Return &mut str from encode_to_slice #72

Open elichai opened 2 years ago

elichai commented 2 years ago

I use this crate a lot, especially in no_std or performance-sensitive environments. and I use encode_to_slice quite a lot, and usually, I need then to convert the slice into an str to pass to a serializer/formatter. I think it makes sense that encode_to_slice will return a &mut str because it just checked all the invariants and can verify that in debug mode.

Sadly this breaks the API in the rare case where the returned () was used, so bumped to 0.5.

elichai commented 2 years ago

The errors are completely unrelated to this PR, I can still fix them if you prefer (although I'm not sure if changing the lint name will break older rustc versions)