// FIXME This module's name is a bit unfortunate, since other modules also import `core::num`.
-use crate::cmp::Ordering::{self, Less, Equal, Greater};
+use crate::cmp::Ordering::{self, Equal, Greater, Less};
pub use crate::num::bignum::Big32x40 as Big;
/// 1. using `FromStr` on `&[u8]` requires `from_utf8_unchecked`, which is bad, and
/// 2. piecing together the results of `integral.parse()` and `fractional.parse()` is
/// more complicated than this entire function.
-pub fn from_str_unchecked<'a, T>(bytes: T) -> u64 where T : IntoIterator<Item=&'a u8> {
+pub fn from_str_unchecked<'a, T>(bytes: T) -> u64
+where
+ T: IntoIterator<Item = &'a u8>,
+{
let mut result = 0;
for &c in bytes {
result = result * 10 + (c - b'0') as u64;
pub fn to_u64(x: &Big) -> u64 {
assert!(x.bit_length() < 64);
let d = x.digits();
- if d.len() < 2 {
- d[0] as u64
- } else {
- (d[1] as u64) << 32 | d[0] as u64
- }
+ if d.len() < 2 { d[0] as u64 } else { (d[1] as u64) << 32 | d[0] as u64 }
}
-
/// Extracts a range of bits.
/// Index 0 is the least significant bit and the range is half-open as usual.