Skip to content

Commit

Permalink
Make sure that the API of both AHasher variants is the same
Browse files Browse the repository at this point in the history
  • Loading branch information
koute committed Sep 17, 2019
1 parent d196c62 commit ea0f0a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/aes_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ pub struct AHasher {
}

impl AHasher {
/// Creates a new hasher keyed to the provided key.
#[inline]
pub fn new_with_key(key: u64) -> AHasher {
AHasher { buffer: [key, !key] }
}

/// Creates a new hasher keyed to the provided keys.
/// # Example
///
Expand Down
2 changes: 1 addition & 1 deletion src/fallback_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl AHasher {

/// Creates a new hasher keyed to the provided keys.
#[inline]
pub(crate) fn new_with_keys(key1: u64, key2: u64) -> AHasher {
pub fn new_with_keys(key1: u64, key2: u64) -> AHasher {
AHasher {
buffer: key1 ^ (key2.rotate_left(ROT)),
}
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,10 @@ mod test {
let bytes: u64 = as_array!(input, 8).convert();
assert_eq!(bytes, 0x6464646464646464);
}

#[test]
fn test_ahasher_construction() {
let _ = AHasher::new_with_key(1234);
let _ = AHasher::new_with_keys(1245, 5678);
}
}

0 comments on commit ea0f0a8

Please sign in to comment.