Skip to content

Commit 3fbbee6

Browse files
committed
rustfmt hash submodule
1 parent 17033a6 commit 3fbbee6

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

src/libcore/hash/mod.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ pub trait Hash {
100100

101101
/// Feeds a slice of this type into the state provided.
102102
#[stable(feature = "hash_slice", since = "1.3.0")]
103-
fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) where Self: Sized {
103+
fn hash_slice<H: Hasher>(data: &[Self], state: &mut H)
104+
where Self: Sized
105+
{
104106
for piece in data {
105107
piece.hash(state);
106108
}
@@ -121,7 +123,9 @@ pub trait Hasher {
121123
/// Write a single `u8` into this hasher
122124
#[inline]
123125
#[stable(feature = "hasher_write", since = "1.3.0")]
124-
fn write_u8(&mut self, i: u8) { self.write(&[i]) }
126+
fn write_u8(&mut self, i: u8) {
127+
self.write(&[i])
128+
}
125129
/// Write a single `u16` into this hasher.
126130
#[inline]
127131
#[stable(feature = "hasher_write", since = "1.3.0")]
@@ -145,32 +149,41 @@ pub trait Hasher {
145149
#[stable(feature = "hasher_write", since = "1.3.0")]
146150
fn write_usize(&mut self, i: usize) {
147151
let bytes = unsafe {
148-
::slice::from_raw_parts(&i as *const usize as *const u8,
149-
mem::size_of::<usize>())
152+
::slice::from_raw_parts(&i as *const usize as *const u8, mem::size_of::<usize>())
150153
};
151154
self.write(bytes);
152155
}
153156

154157
/// Write a single `i8` into this hasher.
155158
#[inline]
156159
#[stable(feature = "hasher_write", since = "1.3.0")]
157-
fn write_i8(&mut self, i: i8) { self.write_u8(i as u8) }
160+
fn write_i8(&mut self, i: i8) {
161+
self.write_u8(i as u8)
162+
}
158163
/// Write a single `i16` into this hasher.
159164
#[inline]
160165
#[stable(feature = "hasher_write", since = "1.3.0")]
161-
fn write_i16(&mut self, i: i16) { self.write_u16(i as u16) }
166+
fn write_i16(&mut self, i: i16) {
167+
self.write_u16(i as u16)
168+
}
162169
/// Write a single `i32` into this hasher.
163170
#[inline]
164171
#[stable(feature = "hasher_write", since = "1.3.0")]
165-
fn write_i32(&mut self, i: i32) { self.write_u32(i as u32) }
172+
fn write_i32(&mut self, i: i32) {
173+
self.write_u32(i as u32)
174+
}
166175
/// Write a single `i64` into this hasher.
167176
#[inline]
168177
#[stable(feature = "hasher_write", since = "1.3.0")]
169-
fn write_i64(&mut self, i: i64) { self.write_u64(i as u64) }
178+
fn write_i64(&mut self, i: i64) {
179+
self.write_u64(i as u64)
180+
}
170181
/// Write a single `isize` into this hasher.
171182
#[inline]
172183
#[stable(feature = "hasher_write", since = "1.3.0")]
173-
fn write_isize(&mut self, i: isize) { self.write_usize(i as usize) }
184+
fn write_isize(&mut self, i: isize) {
185+
self.write_usize(i as usize)
186+
}
174187
}
175188

176189
//////////////////////////////////////////////////////////////////////////////

src/libcore/hash/sip.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ pub struct SipHasher {
3737
// and simd implementations of SipHash will use vectors
3838
// of v02 and v13. By placing them in this order in the struct,
3939
// the compiler can pick up on just a few simd optimizations by itself.
40-
v0: u64, // hash state
40+
v0: u64, // hash state
4141
v2: u64,
4242
v1: u64,
4343
v3: u64,
4444
tail: u64, // unprocessed bytes le
45-
ntail: usize, // how many bytes in tail are valid
45+
ntail: usize, // how many bytes in tail are valid
4646
}
4747

4848
// sadly, these macro definitions can't appear later,
@@ -80,8 +80,7 @@ macro_rules! u8to64_le {
8080
unsafe fn load_u64_le(buf: &[u8], i: usize) -> u64 {
8181
debug_assert!(i + 8 <= buf.len());
8282
let mut data = 0u64;
83-
ptr::copy_nonoverlapping(buf.get_unchecked(i),
84-
&mut data as *mut _ as *mut u8, 8);
83+
ptr::copy_nonoverlapping(buf.get_unchecked(i), &mut data as *mut _ as *mut u8, 8);
8584
data.to_le()
8685
}
8786

@@ -152,12 +151,12 @@ impl Hasher for SipHasher {
152151
if self.ntail != 0 {
153152
needed = 8 - self.ntail;
154153
if length < needed {
155-
self.tail |= u8to64_le!(msg, 0, length) << 8*self.ntail;
154+
self.tail |= u8to64_le!(msg, 0, length) << 8 * self.ntail;
156155
self.ntail += length;
157156
return
158157
}
159158

160-
let m = self.tail | u8to64_le!(msg, 0, needed) << 8*self.ntail;
159+
let m = self.tail | u8to64_le!(msg, 0, needed) << 8 * self.ntail;
161160

162161
self.v3 ^= m;
163162
compress!(self.v0, self.v1, self.v2, self.v3);

0 commit comments

Comments
 (0)