]> git.proxmox.com Git - rustc.git/blobdiff - src/libcore/num/dec2flt/num.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / libcore / num / dec2flt / num.rs
index 4d50516ce546bb79e4461ee0c98a0da10fd04614..208783dd32fd5df8c271cbb0c69e308b4f3e1f2b 100644 (file)
@@ -2,7 +2,7 @@
 
 // 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;
 
@@ -36,7 +36,10 @@ pub fn compare_with_half_ulp(f: &Big, ones_place: usize) -> Ordering {
 /// 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;
@@ -61,14 +64,9 @@ pub fn digits_to_big(integral: &[u8], fractional: &[u8]) -> Big {
 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.