let RefMut { value, borrow } = orig;
RefMut {
value: f(value),
- borrow: borrow,
+ borrow,
}
}
match borrow.get() {
UNUSED => {
borrow.set(UNUSED - 1);
- Some(BorrowRefMut { borrow: borrow })
+ Some(BorrowRefMut { borrow })
},
_ => None,
}
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub const fn new(value: T) -> UnsafeCell<T> {
- UnsafeCell { value: value }
+ UnsafeCell { value }
}
/// Unwraps the value.
fn map<B, F>(self, f: F) -> Map<Self, F> where
Self: Sized, F: FnMut(Self::Item) -> B,
{
- Map{iter: self, f: f}
+ Map { iter: self, f }
}
/// Calls a closure on each element of an iterator.
fn filter<P>(self, predicate: P) -> Filter<Self, P> where
Self: Sized, P: FnMut(&Self::Item) -> bool,
{
- Filter{iter: self, predicate: predicate}
+ Filter {iter: self, predicate }
}
/// Creates an iterator that both filters and maps.
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
Self: Sized, F: FnMut(Self::Item) -> Option<B>,
{
- FilterMap { iter: self, f: f }
+ FilterMap { iter: self, f }
}
/// Creates an iterator which gives the current iteration count as well as
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
Self: Sized, P: FnMut(&Self::Item) -> bool,
{
- SkipWhile{iter: self, flag: false, predicate: predicate}
+ SkipWhile { iter: self, flag: false, predicate }
}
/// Creates an iterator that yields elements based on a predicate.
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
Self: Sized, P: FnMut(&Self::Item) -> bool,
{
- TakeWhile{iter: self, flag: false, predicate: predicate}
+ TakeWhile { iter: self, flag: false, predicate }
}
/// Creates an iterator that skips the first `n` elements.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn skip(self, n: usize) -> Skip<Self> where Self: Sized {
- Skip{iter: self, n: n}
+ Skip { iter: self, n }
}
/// Creates an iterator that yields its first `n` elements.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn take(self, n: usize) -> Take<Self> where Self: Sized, {
- Take{iter: self, n: n}
+ Take { iter: self, n }
}
/// An iterator adaptor similar to [`fold`] that holds internal state and
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>,
{
- Scan{iter: self, f: f, state: initial_state}
+ Scan { iter: self, f, state: initial_state }
}
/// Creates an iterator that works like map, but flattens nested structure.
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
Self: Sized, F: FnMut(&Self::Item),
{
- Inspect{iter: self, f: f}
+ Inspect { iter: self, f }
}
/// Borrows an iterator, rather than consuming it.
impl<'a> Decimal<'a> {
pub fn new(integral: &'a [u8], fractional: &'a [u8], exp: i64) -> Decimal<'a> {
- Decimal { integral: integral, fractional: fractional, exp: exp }
+ Decimal { integral, fractional, exp }
}
}
impl Unpacked {
pub fn new(sig: u64, k: i16) -> Self {
- Unpacked { sig: sig, k: k }
+ Unpacked { sig, k }
}
}
// We cut off all bits prior to the index `start`, i.e., we effectively right-shift by
// an amount of `start`, so this is also the exponent we need.
let e = start as i16;
- let rounded_down = Fp { f: leading, e: e }.normalize();
+ let rounded_down = Fp { f: leading, e }.normalize();
// Round (half-to-even) depending on the truncated bits.
match num::compare_with_half_ulp(f, start) {
Less => rounded_down,
Equal if leading % 2 == 0 => rounded_down,
Equal | Greater => match leading.checked_add(1) {
- Some(f) => Fp { f: f, e: e }.normalize(),
+ Some(f) => Fp { f, e }.normalize(),
None => Fp { f: 1 << 63, e: e + 1 },
}
}
let tmp = (bd >> 32) + (ad & MASK) + (bc & MASK) + (1 << 31) /* round */;
let f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
let e = self.e + other.e + 64;
- Fp { f: f, e: e }
+ Fp { f, e }
}
/// Normalizes itself so that the resulting mantissa is at least `2^63`.
e -= 1;
}
debug_assert!(f >= (1 >> 63));
- Fp { f: f, e: e }
+ Fp { f, e }
}
/// Normalizes itself to have the shared exponent.
// neighbors: (mant - 2, exp) -- (mant, exp) -- (mant + 2, exp)
// Float::integer_decode always preserves the exponent,
// so the mantissa is scaled for subnormals.
- FullDecoded::Finite(Decoded { mant: mant, minus: 1, plus: 1,
- exp: exp, inclusive: even })
+ FullDecoded::Finite(Decoded { mant, minus: 1, plus: 1,
+ exp, inclusive: even })
}
FpCategory::Normal => {
let minnorm = <T as DecodableFloat>::min_pos_norm_value().integer_decode();
match full_decoded {
FullDecoded::Nan => {
parts[0] = Part::Copy(b"NaN");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
FullDecoded::Infinite => {
parts[0] = Part::Copy(b"inf");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
FullDecoded::Zero => {
if frac_digits > 0 { // [0.][0000]
parts[0] = Part::Copy(b"0.");
parts[1] = Part::Zero(frac_digits);
- Formatted { sign: sign, parts: &parts[..2] }
+ Formatted { sign, parts: &parts[..2] }
} else {
parts[0] = Part::Copy(b"0");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
}
FullDecoded::Finite(ref decoded) => {
match full_decoded {
FullDecoded::Nan => {
parts[0] = Part::Copy(b"NaN");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
FullDecoded::Infinite => {
parts[0] = Part::Copy(b"inf");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
FullDecoded::Zero => {
parts[0] = if dec_bounds.0 <= 0 && 0 < dec_bounds.1 {
} else {
Part::Copy(if upper { b"0E0" } else { b"0e0" })
};
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
FullDecoded::Finite(ref decoded) => {
let (len, exp) = format_shortest(decoded, buf);
} else {
digits_to_exp_str(&buf[..len], exp, 0, upper, parts)
};
- Formatted { sign: sign, parts: parts }
+ Formatted { sign, parts }
}
}
}
match full_decoded {
FullDecoded::Nan => {
parts[0] = Part::Copy(b"NaN");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
FullDecoded::Infinite => {
parts[0] = Part::Copy(b"inf");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
FullDecoded::Zero => {
if ndigits > 1 { // [0.][0000][e0]
parts[0] = Part::Copy(b"0.");
parts[1] = Part::Zero(ndigits - 1);
parts[2] = Part::Copy(if upper { b"E0" } else { b"e0" });
- Formatted { sign: sign, parts: &parts[..3] }
+ Formatted { sign, parts: &parts[..3] }
} else {
parts[0] = Part::Copy(if upper { b"0E0" } else { b"0e0" });
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
}
FullDecoded::Finite(ref decoded) => {
match full_decoded {
FullDecoded::Nan => {
parts[0] = Part::Copy(b"NaN");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
FullDecoded::Infinite => {
parts[0] = Part::Copy(b"inf");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
FullDecoded::Zero => {
if frac_digits > 0 { // [0.][0000]
parts[0] = Part::Copy(b"0.");
parts[1] = Part::Zero(frac_digits);
- Formatted { sign: sign, parts: &parts[..2] }
+ Formatted { sign, parts: &parts[..2] }
} else {
parts[0] = Part::Copy(b"0");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
}
FullDecoded::Finite(ref decoded) => {
if frac_digits > 0 { // [0.][0000]
parts[0] = Part::Copy(b"0.");
parts[1] = Part::Zero(frac_digits);
- Formatted { sign: sign, parts: &parts[..2] }
+ Formatted { sign, parts: &parts[..2] }
} else {
parts[0] = Part::Copy(b"0");
- Formatted { sign: sign, parts: &parts[..1] }
+ Formatted { sign, parts: &parts[..1] }
}
} else {
Formatted { sign,
let idx = ((gamma as i32) - offset) * range / domain;
let (f, e, k) = CACHED_POW10[idx as usize];
debug_assert!(alpha <= e && e <= gamma);
- (k, Fp { f: f, e: e })
+ (k, Fp { f, e })
}
/// Given `x > 0`, returns `(k, 10^k)` such that `10^k <= x < 10^(k+1)`.
#[inline]
pub fn windows(&self, size: usize) -> Windows<T> {
assert!(size != 0);
- Windows { v: self, size: size }
+ Windows { v: self, size }
}
/// Returns an iterator over `chunk_size` elements of the slice at a
#[inline]
pub fn chunks(&self, chunk_size: usize) -> Chunks<T> {
assert!(chunk_size != 0);
- Chunks { v: self, chunk_size: chunk_size }
+ Chunks { v: self, chunk_size }
}
/// Returns an iterator over `chunk_size` elements of the slice at a time.
#[inline]
pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<T> {
assert!(chunk_size != 0);
- ChunksMut { v: self, chunk_size: chunk_size }
+ ChunksMut { v: self, chunk_size }
}
/// Returns an iterator over `chunk_size` elements of the slice at a
let rem = self.len() % chunk_size;
let len = self.len() - rem;
let (fst, snd) = self.split_at(len);
- ExactChunks { v: fst, rem: snd, chunk_size: chunk_size}
+ ExactChunks { v: fst, rem: snd, chunk_size }
}
/// Returns an iterator over `chunk_size` elements of the slice at a time.
let rem = self.len() % chunk_size;
let len = self.len() - rem;
let (fst, snd) = self.split_at_mut(len);
- ExactChunksMut { v: fst, rem: snd, chunk_size: chunk_size}
+ ExactChunksMut { v: fst, rem: snd, chunk_size }
}
/// Divides one slice into two at an index.
pub fn split_mut<F>(&mut self, pred: F) -> SplitMut<T, F>
where F: FnMut(&T) -> bool
{
- SplitMut { v: self, pred: pred, finished: false }
+ SplitMut { v: self, pred, finished: false }
}
/// Returns an iterator over subslices separated by elements that match
{
Context {
local_waker: self.local_waker,
- executor: executor,
+ executor,
}
}
}
let secs = secs.checked_add((nanos / NANOS_PER_SEC) as u64)
.expect("overflow in Duration::new");
let nanos = nanos % NANOS_PER_SEC;
- Duration { secs: secs, nanos: nanos }
+ Duration { secs, nanos }
}
/// Creates a new `Duration` from the specified number of whole seconds.
#[stable(feature = "duration", since = "1.3.0")]
#[inline]
pub const fn from_secs(secs: u64) -> Duration {
- Duration { secs: secs, nanos: 0 }
+ Duration { secs, nanos: 0 }
}
/// Creates a new `Duration` from the specified number of milliseconds.
}
};
debug_assert!(nanos < NANOS_PER_SEC);
- Some(Duration { secs: secs, nanos: nanos })
+ Some(Duration { secs, nanos })
} else {
None
}
let extra_nanos = carry * (NANOS_PER_SEC as u64) / (rhs as u64);
let nanos = self.nanos / rhs + (extra_nanos as u32);
debug_assert!(nanos < NANOS_PER_SEC);
- Some(Duration { secs: secs, nanos: nanos })
+ Some(Duration { secs, nanos })
} else {
None
}