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
201 stars 55 forks source link

Implement FromHex for 32-byte arrays #13

Closed illicitonion closed 6 years ago

LukasKalbertodt commented 6 years ago

Hello and thanks for your PR! Adding one specific array length begs the question: why not other lengths? We could, for example, add all multiple of 8 below or equal to 64 (24, 32, 40, 48, 56, 64). I'm not sure what's the right solution here. Any other opinions?

illicitonion commented 6 years ago

I'm happy to add multiples of 8 up to some value, I just had a need for 32 because it's a pretty common digest algorithm output size (and one I'm using).

Longer-term, I think https://github.com/rust-lang/rust/issues/44580 means we should be able to make this generic in the future (its RFC got accepted, and someone is interested in working on it).

LukasKalbertodt commented 6 years ago

Yip, absolutely, the current situation is just a dirty hack. Anyway, I'm not the maintainer of this crate, so you' (we) will have to wait for @KokaKiwi to decide what numbers to add ^_^

KokaKiwi commented 6 years ago

Hi, long time I haven't been active here (kind of a chaotic schedule recently, in my head too ^^") I think of adding some sizes to implement, but that's purely arbitrary at the moment (as Lukas said, that's just dirty hack in waiting for the RFC): 24, 48 and 64 (multiples of 16 between 16 and 64 seemed to be a good thing to me)

illicitonion commented 6 years ago

Done :) Thanks!