Skip to content

Commit 5457c35

Browse files
committed
run rustfmt on libcore/num folder
1 parent acb50e3 commit 5457c35

File tree

6 files changed

+112
-54
lines changed

6 files changed

+112
-54
lines changed

src/libcore/num/bignum.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,22 @@ use intrinsics;
3434
pub trait FullOps: Sized {
3535
/// Returns `(carry', v')` such that `carry' * 2^W + v' = self + other + carry`,
3636
/// where `W` is the number of bits in `Self`.
37-
fn full_add(self, other: Self, carry: bool) -> (bool /*carry*/, Self);
37+
fn full_add(self, other: Self, carry: bool) -> (bool /* carry */, Self);
3838

3939
/// Returns `(carry', v')` such that `carry' * 2^W + v' = self * other + carry`,
4040
/// where `W` is the number of bits in `Self`.
41-
fn full_mul(self, other: Self, carry: Self) -> (Self /*carry*/, Self);
41+
fn full_mul(self, other: Self, carry: Self) -> (Self /* carry */, Self);
4242

4343
/// Returns `(carry', v')` such that `carry' * 2^W + v' = self * other + other2 + carry`,
4444
/// where `W` is the number of bits in `Self`.
45-
fn full_mul_add(self, other: Self, other2: Self, carry: Self) -> (Self /*carry*/, Self);
45+
fn full_mul_add(self, other: Self, other2: Self, carry: Self) -> (Self /* carry */, Self);
4646

4747
/// Returns `(quo, rem)` such that `borrow * 2^W + self = quo * other + rem`
4848
/// and `0 <= rem < other`, where `W` is the number of bits in `Self`.
49-
fn full_div_rem(self, other: Self, borrow: Self) -> (Self /*quotient*/, Self /*remainder*/);
49+
fn full_div_rem(self,
50+
other: Self,
51+
borrow: Self)
52+
-> (Self /* quotient */, Self /* remainder */);
5053
}
5154

5255
macro_rules! impl_full_ops {
@@ -100,11 +103,7 @@ impl_full_ops! {
100103

101104
/// Table of powers of 5 representable in digits. Specifically, the largest {u8, u16, u32} value
102105
/// that's a power of five, plus the corresponding exponent. Used in `mul_pow5`.
103-
const SMALL_POW5: [(u64, usize); 3] = [
104-
(125, 3),
105-
(15625, 6),
106-
(1_220_703_125, 13),
107-
];
106+
const SMALL_POW5: [(u64, usize); 3] = [(125, 3), (15625, 6), (1_220_703_125, 13)];
108107

109108
macro_rules! define_bignum {
110109
($name:ident: type=$ty:ty, n=$n:expr) => (

src/libcore/num/diy_float.rs

+28-7
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,30 @@ impl Fp {
4949
pub fn normalize(&self) -> Fp {
5050
let mut f = self.f;
5151
let mut e = self.e;
52-
if f >> (64 - 32) == 0 { f <<= 32; e -= 32; }
53-
if f >> (64 - 16) == 0 { f <<= 16; e -= 16; }
54-
if f >> (64 - 8) == 0 { f <<= 8; e -= 8; }
55-
if f >> (64 - 4) == 0 { f <<= 4; e -= 4; }
56-
if f >> (64 - 2) == 0 { f <<= 2; e -= 2; }
57-
if f >> (64 - 1) == 0 { f <<= 1; e -= 1; }
52+
if f >> (64 - 32) == 0 {
53+
f <<= 32;
54+
e -= 32;
55+
}
56+
if f >> (64 - 16) == 0 {
57+
f <<= 16;
58+
e -= 16;
59+
}
60+
if f >> (64 - 8) == 0 {
61+
f <<= 8;
62+
e -= 8;
63+
}
64+
if f >> (64 - 4) == 0 {
65+
f <<= 4;
66+
e -= 4;
67+
}
68+
if f >> (64 - 2) == 0 {
69+
f <<= 2;
70+
e -= 2;
71+
}
72+
if f >> (64 - 1) == 0 {
73+
f <<= 1;
74+
e -= 1;
75+
}
5876
debug_assert!(f >= (1 >> 63));
5977
Fp { f: f, e: e }
6078
}
@@ -66,6 +84,9 @@ impl Fp {
6684
assert!(edelta >= 0);
6785
let edelta = edelta as usize;
6886
assert_eq!(self.f << edelta >> edelta, self.f);
69-
Fp { f: self.f << edelta, e: e }
87+
Fp {
88+
f: self.f << edelta,
89+
e: e,
90+
}
7091
}
7192
}

src/libcore/num/f32.rs

+33-15
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ pub const MAX_10_EXP: i32 = 38;
6161

6262
/// Not a Number (NaN).
6363
#[stable(feature = "rust1", since = "1.0.0")]
64-
pub const NAN: f32 = 0.0_f32/0.0_f32;
64+
pub const NAN: f32 = 0.0_f32 / 0.0_f32;
6565
/// Infinity (∞).
6666
#[stable(feature = "rust1", since = "1.0.0")]
67-
pub const INFINITY: f32 = 1.0_f32/0.0_f32;
67+
pub const INFINITY: f32 = 1.0_f32 / 0.0_f32;
6868
/// Negative infinity (-∞).
6969
#[stable(feature = "rust1", since = "1.0.0")]
70-
pub const NEG_INFINITY: f32 = -1.0_f32/0.0_f32;
70+
pub const NEG_INFINITY: f32 = -1.0_f32 / 0.0_f32;
7171

7272
/// Basic mathematical constants.
7373
#[stable(feature = "rust1", since = "1.0.0")]
@@ -144,26 +144,40 @@ pub mod consts {
144144
issue = "32110")]
145145
impl Float for f32 {
146146
#[inline]
147-
fn nan() -> f32 { NAN }
147+
fn nan() -> f32 {
148+
NAN
149+
}
148150

149151
#[inline]
150-
fn infinity() -> f32 { INFINITY }
152+
fn infinity() -> f32 {
153+
INFINITY
154+
}
151155

152156
#[inline]
153-
fn neg_infinity() -> f32 { NEG_INFINITY }
157+
fn neg_infinity() -> f32 {
158+
NEG_INFINITY
159+
}
154160

155161
#[inline]
156-
fn zero() -> f32 { 0.0 }
162+
fn zero() -> f32 {
163+
0.0
164+
}
157165

158166
#[inline]
159-
fn neg_zero() -> f32 { -0.0 }
167+
fn neg_zero() -> f32 {
168+
-0.0
169+
}
160170

161171
#[inline]
162-
fn one() -> f32 { 1.0 }
172+
fn one() -> f32 {
173+
1.0
174+
}
163175

164176
/// Returns `true` if the number is NaN.
165177
#[inline]
166-
fn is_nan(self) -> bool { self != self }
178+
fn is_nan(self) -> bool {
179+
self != self
180+
}
167181

168182
/// Returns `true` if the number is infinite.
169183
#[inline]
@@ -192,11 +206,11 @@ impl Float for f32 {
192206

193207
let bits: u32 = unsafe { mem::transmute(self) };
194208
match (bits & MAN_MASK, bits & EXP_MASK) {
195-
(0, 0) => Fp::Zero,
196-
(_, 0) => Fp::Subnormal,
209+
(0, 0) => Fp::Zero,
210+
(_, 0) => Fp::Subnormal,
197211
(0, EXP_MASK) => Fp::Infinite,
198212
(_, EXP_MASK) => Fp::Nan,
199-
_ => Fp::Normal,
213+
_ => Fp::Normal,
200214
}
201215
}
202216

@@ -252,7 +266,9 @@ impl Float for f32 {
252266

253267
/// Returns the reciprocal (multiplicative inverse) of the number.
254268
#[inline]
255-
fn recip(self) -> f32 { 1.0 / self }
269+
fn recip(self) -> f32 {
270+
1.0 / self
271+
}
256272

257273
#[inline]
258274
fn powi(self, n: i32) -> f32 {
@@ -261,7 +277,9 @@ impl Float for f32 {
261277

262278
/// Converts to degrees, assuming the number is in radians.
263279
#[inline]
264-
fn to_degrees(self) -> f32 { self * (180.0f32 / consts::PI) }
280+
fn to_degrees(self) -> f32 {
281+
self * (180.0f32 / consts::PI)
282+
}
265283

266284
/// Converts to radians, assuming the number is in degrees.
267285
#[inline]

src/libcore/num/f64.rs

+33-15
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ pub const MAX_10_EXP: i32 = 308;
6161

6262
/// Not a Number (NaN).
6363
#[stable(feature = "rust1", since = "1.0.0")]
64-
pub const NAN: f64 = 0.0_f64/0.0_f64;
64+
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
6565
/// Infinity (∞).
6666
#[stable(feature = "rust1", since = "1.0.0")]
67-
pub const INFINITY: f64 = 1.0_f64/0.0_f64;
67+
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
6868
/// Negative infinity (-∞).
6969
#[stable(feature = "rust1", since = "1.0.0")]
70-
pub const NEG_INFINITY: f64 = -1.0_f64/0.0_f64;
70+
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
7171

7272
/// Basic mathematical constants.
7373
#[stable(feature = "rust1", since = "1.0.0")]
@@ -144,26 +144,40 @@ pub mod consts {
144144
issue = "32110")]
145145
impl Float for f64 {
146146
#[inline]
147-
fn nan() -> f64 { NAN }
147+
fn nan() -> f64 {
148+
NAN
149+
}
148150

149151
#[inline]
150-
fn infinity() -> f64 { INFINITY }
152+
fn infinity() -> f64 {
153+
INFINITY
154+
}
151155

152156
#[inline]
153-
fn neg_infinity() -> f64 { NEG_INFINITY }
157+
fn neg_infinity() -> f64 {
158+
NEG_INFINITY
159+
}
154160

155161
#[inline]
156-
fn zero() -> f64 { 0.0 }
162+
fn zero() -> f64 {
163+
0.0
164+
}
157165

158166
#[inline]
159-
fn neg_zero() -> f64 { -0.0 }
167+
fn neg_zero() -> f64 {
168+
-0.0
169+
}
160170

161171
#[inline]
162-
fn one() -> f64 { 1.0 }
172+
fn one() -> f64 {
173+
1.0
174+
}
163175

164176
/// Returns `true` if the number is NaN.
165177
#[inline]
166-
fn is_nan(self) -> bool { self != self }
178+
fn is_nan(self) -> bool {
179+
self != self
180+
}
167181

168182
/// Returns `true` if the number is infinite.
169183
#[inline]
@@ -192,11 +206,11 @@ impl Float for f64 {
192206

193207
let bits: u64 = unsafe { mem::transmute(self) };
194208
match (bits & MAN_MASK, bits & EXP_MASK) {
195-
(0, 0) => Fp::Zero,
196-
(_, 0) => Fp::Subnormal,
209+
(0, 0) => Fp::Zero,
210+
(_, 0) => Fp::Subnormal,
197211
(0, EXP_MASK) => Fp::Infinite,
198212
(_, EXP_MASK) => Fp::Nan,
199-
_ => Fp::Normal,
213+
_ => Fp::Normal,
200214
}
201215
}
202216

@@ -252,7 +266,9 @@ impl Float for f64 {
252266

253267
/// Returns the reciprocal (multiplicative inverse) of the number.
254268
#[inline]
255-
fn recip(self) -> f64 { 1.0 / self }
269+
fn recip(self) -> f64 {
270+
1.0 / self
271+
}
256272

257273
#[inline]
258274
fn powi(self, n: i32) -> f64 {
@@ -261,7 +277,9 @@ impl Float for f64 {
261277

262278
/// Converts to degrees, assuming the number is in radians.
263279
#[inline]
264-
fn to_degrees(self) -> f64 { self * (180.0f64 / consts::PI) }
280+
fn to_degrees(self) -> f64 {
281+
self * (180.0f64 / consts::PI)
282+
}
265283

266284
/// Converts to radians, assuming the number is in degrees.
267285
#[inline]

src/libcore/num/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ use str::FromStr;
4343
/// ```
4444
#[stable(feature = "rust1", since = "1.0.0")]
4545
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)]
46-
pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
46+
pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")]
47+
pub T);
4748

4849
#[stable(feature = "rust1", since = "1.0.0")]
4950
impl<T: fmt::Debug> fmt::Debug for Wrapping<T> {
@@ -2402,7 +2403,7 @@ pub enum FpCategory {
24022403

24032404
/// Positive or negative infinity.
24042405
#[stable(feature = "rust1", since = "1.0.0")]
2405-
Infinite ,
2406+
Infinite,
24062407

24072408
/// Positive or negative zero.
24082409
#[stable(feature = "rust1", since = "1.0.0")]
@@ -2662,8 +2663,7 @@ macro_rules! doit {
26622663
}
26632664
doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
26642665

2665-
fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32)
2666-
-> Result<T, ParseIntError> {
2666+
fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, ParseIntError> {
26672667
use self::IntErrorKind::*;
26682668
use self::ParseIntError as PIE;
26692669

@@ -2686,7 +2686,7 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32)
26862686
let (is_positive, digits) = match src[0] {
26872687
b'+' => (true, &src[1..]),
26882688
b'-' if is_signed_ty => (false, &src[1..]),
2689-
_ => (true, src)
2689+
_ => (true, src),
26902690
};
26912691

26922692
if digits.is_empty() {
@@ -2738,7 +2738,9 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32)
27382738
/// [`i8::from_str_radix()`]: ../../std/primitive.i8.html#method.from_str_radix
27392739
#[derive(Debug, Clone, PartialEq, Eq)]
27402740
#[stable(feature = "rust1", since = "1.0.0")]
2741-
pub struct ParseIntError { kind: IntErrorKind }
2741+
pub struct ParseIntError {
2742+
kind: IntErrorKind,
2743+
}
27422744

27432745
#[derive(Debug, Clone, PartialEq, Eq)]
27442746
enum IntErrorKind {

src/libcore/num/wrapping.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,13 @@ mod shift_max {
310310
pub const isize: u32 = super::i64;
311311
}
312312

313-
pub const i8: u32 = (1 << 3) - 1;
313+
pub const i8: u32 = (1 << 3) - 1;
314314
pub const i16: u32 = (1 << 4) - 1;
315315
pub const i32: u32 = (1 << 5) - 1;
316316
pub const i64: u32 = (1 << 6) - 1;
317317
pub use self::platform::isize;
318318

319-
pub const u8: u32 = i8;
319+
pub const u8: u32 = i8;
320320
pub const u16: u32 = i16;
321321
pub const u32: u32 = i32;
322322
pub const u64: u32 = i64;

0 commit comments

Comments
 (0)