@@ -70,14 +70,14 @@ pub trait ExtendedHasher: Hasher {
70
70
///
71
71
/// ```
72
72
/// use rustc_stable_hash::hashers::{StableSipHasher128, SipHasher128Hash};
73
- /// use rustc_stable_hash::{StableHasher, StableHasherResult };
73
+ /// use rustc_stable_hash::{StableHasher, FromStableHash };
74
74
/// use std::hash::Hasher;
75
75
///
76
76
/// struct Hash128([u64; 2]);
77
- /// impl StableHasherResult for Hash128 {
77
+ /// impl FromStableHash for Hash128 {
78
78
/// type Hash = SipHasher128Hash;
79
79
///
80
- /// fn finish (SipHasher128Hash(hash): SipHasher128Hash) -> Hash128 {
80
+ /// fn from (SipHasher128Hash(hash): SipHasher128Hash) -> Hash128 {
81
81
/// Hash128(hash)
82
82
/// }
83
83
/// }
@@ -92,32 +92,32 @@ pub struct StableHasher<H: ExtendedHasher> {
92
92
state : H ,
93
93
}
94
94
95
- /// Trait for retrieving the result of the stable hashing operation.
95
+ /// Trait for processing the result of the stable hashing operation.
96
96
///
97
97
/// # Example
98
98
///
99
99
/// ```
100
- /// use rustc_stable_hash::{StableHasher, StableHasherResult };
100
+ /// use rustc_stable_hash::{StableHasher, FromStableHash };
101
101
///
102
102
/// struct Hash128(u128);
103
103
///
104
- /// impl StableHasherResult for Hash128 {
104
+ /// impl FromStableHash for Hash128 {
105
105
/// type Hash = [u64; 2];
106
106
///
107
- /// fn finish (hash: [u64; 2]) -> Hash128 {
107
+ /// fn from (hash: [u64; 2]) -> Hash128 {
108
108
/// let upper: u128 = hash[0] as u128;
109
109
/// let lower: u128 = hash[1] as u128;
110
110
///
111
111
/// Hash128((upper << 64) | lower)
112
112
/// }
113
113
/// }
114
114
/// ```
115
- pub trait StableHasherResult : Sized {
115
+ pub trait FromStableHash : Sized {
116
116
type Hash ;
117
117
118
- /// Retrieving the finalized state of the [`StableHasher`] and construct
119
- /// an [`Self`] containing the hash.
120
- fn finish ( hash : Self :: Hash ) -> Self ;
118
+ /// Convert the finalized state of a [`StableHasher`] and construct
119
+ /// an [`Self`] containing the processed hash.
120
+ fn from ( hash : Self :: Hash ) -> Self ;
121
121
}
122
122
123
123
impl < H : ExtendedHasher + Default > StableHasher < H > {
@@ -161,13 +161,13 @@ impl<H: ExtendedHasher> StableHasher<H> {
161
161
/// Returns the typed-hash value for the values written.
162
162
///
163
163
/// The resulting typed-hash value is constructed from an
164
- /// [`StableHasherResult `] implemenation.
164
+ /// [`FromStableHash `] implemenation.
165
165
///
166
166
/// To be used in-place of [`Hasher::finish`].
167
167
#[ inline]
168
168
#[ must_use]
169
- pub fn finish < W : StableHasherResult < Hash = H :: Hash > > ( self ) -> W {
170
- W :: finish ( self . state . finish ( ) )
169
+ pub fn finish < W : FromStableHash < Hash = H :: Hash > > ( self ) -> W {
170
+ W :: from ( self . state . finish ( ) )
171
171
}
172
172
}
173
173
0 commit comments