浏览代码

Auto merge of #176 - murarth:bigint-bits, r=cuviper

Expose `BigUint::bits` through `BigInt`
Homu 9 年之前
父节点
当前提交
7eb666f6b8
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/bigint.rs

+ 5 - 0
src/bigint.rs

@@ -2750,6 +2750,11 @@ impl BigInt {
         str::from_utf8(buf).ok().and_then(|s| BigInt::from_str_radix(s, radix).ok())
     }
 
+    /// Determines the fewest bits necessary to express the `BigInt`,
+    /// not including the sign.
+    pub fn bits(&self) -> usize {
+        self.data.bits()
+    }
 
     /// Converts this `BigInt` into a `BigUint`, if it's not negative.
     #[inline]