pub trait ToHexExt {
/// Encode the hex strict representing `self` into the result with prefix `0x`. Lower case
/// letters are used (e.g. `f9b4ca`)
fn encode_hex_with_prefix<T: iter::FromIterator<char>>(&self) -> T;
/// Encode the hex strict representing `self` into the result with prefix `0X`. Upper case
/// letters are used (e.g. `F9B4CA`)
fn encode_hex_upper_with_prefix<T: iter::FromIterator<char>>(&self) -> T;
}
impl <T: ToHex + AsRef<[u8]> >ToHexExt for T {
fn encode_hex_with_prefix<U: iter::FromIterator<char>>(&self) -> U {
encode_to_iter(HEX_CHARS_LOWER, &["0x".as_ref(), self.as_ref()].concat())
}
fn encode_hex_upper_with_prefix<U: iter::FromIterator<char>>(&self) -> U {
encode_to_iter(HEX_CHARS_UPPER, &["0X".as_ref(), self.as_ref()].concat())
}
}
But I find that maybe need a ext subdir for doing such work for all apis.
Such as:
But I find that maybe need a
ext
subdir for doing such work for all apis.