pub fn hex_append<'a>(src: &[u8], dst: &'a mut String) -> &'a mut strAvailable on crate feature
alloc only.Expand description
Appends lowercase hexadecimal digits to dst and returns the appended suffix.
Existing text is preserved, including non-ASCII text. The returned mutable
string borrows only dst and contains exactly src.len() * 2 new ASCII
digits. Empty input returns an empty suffix without changing the string.
Available with alloc. Existing capacity is reused without allocation when
sufficient; otherwise the string grows. Call String::clear first to
replace its contents while retaining the allocation. For a new string, use
hex_string.
§Panics
Panics if the resulting length cannot be represented or exceeds isize::MAX
bytes. Allocation failure follows the allocator’s error handling.
§Examples
use faster_hex::hex_append;
let mut text = String::with_capacity(64);
text.push_str("hash: ");
assert_eq!(hex_append(&[0xab, 0xcd], &mut text), "abcd");
assert_eq!(text, "hash: abcd");
text.clear();
hex_append(&[0, 1], &mut text);
assert_eq!(text, "0001");