Skip to content

Commit

Permalink
Improve siphash's as_u64 -> to_u64 rename
Browse files Browse the repository at this point in the history
The previous change was just a dumb rename with no deprecation and it
also kept the `self` type which should be taken by value since the hash
is `Copy`. This improves on it by adding a deprecated method of the
original name and changing the type to be `self` instead of `&self`.
  • Loading branch information
Kixunil committed Aug 23, 2024
1 parent 1a91492 commit 6e5bd47
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hashes/src/siphash24.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ impl Hash {
}

/// Returns the (little endian) 64-bit integer representation of the hash value.
pub fn to_u64(&self) -> u64 { u64::from_le_bytes(self.0) }
#[deprecated(since = "TBD", note = "use `to_u64` instead")]
pub fn as_u64(&self) -> u64 { self.to_u64() }

/// Returns the (little endian) 64-bit integer representation of the hash value.
pub fn to_u64(self) -> u64 { u64::from_le_bytes(self.0) }

/// Creates a hash from its (little endian) 64-bit integer representation.
pub fn from_u64(hash: u64) -> Hash { Hash(hash.to_le_bytes()) }
Expand Down

0 comments on commit 6e5bd47

Please sign in to comment.