Open cgwalters opened 2 years ago
Another alternative is to just make BytesToHexChars
public.
OK this is also much cleaner using String::extend
and even better will honor the size hint.
I rolled in https://github.com/KokaKiwi/rust-hex/pull/67 here.
In https://github.com/ostreedev/ostree-rs-ext/ we are performing hex encoding in loops and recursively, and it could be helpful for performance to support re-using a buffer instead of allocating a new
String
on the heap.Currently we are using
encode_to_slice
, but then we need to use e.g.std::str::from_utf8
which unnecessarily performs UTF-8 validation and is also hence fallible even though it doesn't need to be.