Logo

Programming-Idioms

History of Idiom 175 > diff from v12 to v13

Edit summary for version 13 by anon:
[Rust] typo

Version 12

2019-09-26, 13:59:25

Version 13

2019-09-27, 02:32:50

Idiom #175 Bytes to hex string

From array a of n bytes, build the equivalent hex string s of 2n digits.
Each byte (256 possible values) is encoded as two hexadecimal characters (16 possible values per digit).

Idiom #175 Bytes to hex string

From array a of n bytes, build the equivalent hex string s of 2n digits.
Each byte (256 possible values) is encoded as two hexadecimal characters (16 possible values per digit).

Extra Keywords
hexa
Extra Keywords
hexa
Imports
use hex::ToHex;
Imports
use hex::ToHex;
Code
let mut s = String::with_capactiy(2 * a.len());
a.write_hex(&mut s).expect("Failed to write");
Code
let mut s = String::with_capacity(2 * a.len());
a.write_hex(&mut s).expect("Failed to write");
Doc URL
https://docs.rs/hex/0.3.2/hex/trait.ToHex.html
Doc URL
https://docs.rs/hex/0.3.2/hex/trait.ToHex.html