瀏覽代碼

Add LowerHex and UpperHex formatting

Colin Davidson 9 年之前
父節點
當前提交
80c4d01b7f
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      src/bigint.rs

+ 12 - 0
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;