const_hex

Function check_raw

source
pub fn check_raw<T: AsRef<[u8]>>(input: T) -> bool
Expand description

Returns true if the input is a valid hex string.

Note that this does not check prefixes or length, but just the contents of the string.

ยงExamples

assert!(const_hex::check_raw("48656c6c6f20776f726c6421"));

// Odd length, but valid hex
assert!(const_hex::check_raw("48656c6c6f20776f726c642"));

// Valid hex string, but the prefix is not valid
assert!(!const_hex::check_raw("0x48656c6c6f20776f726c6421"));

assert!(!const_hex::check_raw("Hello world!"));