Nicer display output for hash types.
This commit is contained in:
parent
787a119f12
commit
1c89b9732d
@ -206,7 +206,10 @@ macro_rules! impl_hash {
|
|||||||
}
|
}
|
||||||
impl fmt::Display for $from {
|
impl fmt::Display for $from {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
(self as &fmt::Debug).fmt(f)
|
for i in self.0[0..3].iter() {
|
||||||
|
try!(write!(f, "{:02x}", i));
|
||||||
|
}
|
||||||
|
write!(f, "…{:02x}", self.0.last().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,10 @@ pub fn h256_from_json(json: &Json) -> H256 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn vec_h256_from_json(json: &Json) -> Vec<H256> {
|
||||||
|
json.as_array().unwrap().iter().map(&h256_from_json).collect()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn u256_from_str(s: &str) -> U256 {
|
pub fn u256_from_str(s: &str) -> U256 {
|
||||||
if s.len() >= 2 && &s[0..2] == "0x" {
|
if s.len() >= 2 && &s[0..2] == "0x" {
|
||||||
U256::from_str(&s[2..]).unwrap_or(U256::from(0))
|
U256::from_str(&s[2..]).unwrap_or(U256::from(0))
|
||||||
|
Loading…
Reference in New Issue
Block a user