From 80c4d01b7ff0c7017e4beb443f4004540f4a6efa Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Sat, 16 Jan 2016 21:52:47 -0800 Subject: [PATCH] Add LowerHex and UpperHex formatting --- src/bigint.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bigint.rs b/src/bigint.rs index 386e749..07de81e 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -242,6 +242,18 @@ impl fmt::Display for BigUint { } } +impl fmt::LowerHex for BigUint { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.to_str_radix(16)) + } +} + +impl fmt::UpperHex for BigUint { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.to_str_radix(16).to_uppercase()) + } +} + impl FromStr for BigUint { type Err = ParseBigIntError;