|
| 1 | +//! rustc encodes a lot of hashes. If hashes are stored as `u64` or `u128`, a `derive(Encodable)` |
| 2 | +//! will apply varint encoding to the hashes, which is less efficient than directly encoding the 8 |
| 3 | +//! or 16 bytes of the hash. |
| 4 | +//! |
| 5 | +//! The types in this module represent 64-bit or 128-bit hashes produced by a `StableHasher`. |
| 6 | +//! `Hash64` and `Hash128` expose some utilty functions to encourage users to not extract the inner |
| 7 | +//! hash value as an integer type and accidentally apply varint encoding to it. |
| 8 | +//! |
| 9 | +//! In contrast with `Fingerprint`, users of these types cannot and should not attempt to construct |
| 10 | +//! and decompose these types into constitutent pieces. The point of these types is only to |
| 11 | +//! connect the fact that they can only be produced by a `StableHasher` to their |
| 12 | +//! `Encode`/`Decode` impls. |
| 13 | +
|
| 14 | +use crate::stable_hasher::{StableHasher, StableHasherResult}; |
1 | 15 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
2 | 16 | use std::fmt;
|
3 | 17 | use std::ops::BitXorAssign;
|
4 |
| -use crate::stable_hasher::{StableHasher, StableHasherResult}; |
5 | 18 |
|
6 | 19 | #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
|
7 | 20 | pub struct Hash64 {
|
@@ -74,9 +87,7 @@ impl Hash128 {
|
74 | 87 |
|
75 | 88 | #[inline]
|
76 | 89 | pub fn wrapping_add(self, other: Self) -> Self {
|
77 |
| - Self { |
78 |
| - inner: self.inner.wrapping_add(other.inner), |
79 |
| - } |
| 90 | + Self { inner: self.inner.wrapping_add(other.inner) } |
80 | 91 | }
|
81 | 92 |
|
82 | 93 | #[inline]
|
|
0 commit comments