mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-30 21:04:35 +01:00
fix hash impl
This commit is contained in:
parent
110457477a
commit
c38a25f102
@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
[0.1.1] - 2019-12-07
|
||||||
|
|
||||||
|
* Fix hash impl
|
||||||
|
|
||||||
[0.1.0] - 2019-12-07
|
[0.1.0] - 2019-12-07
|
||||||
|
|
||||||
* Initial release
|
* Initial release
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bytestring"
|
name = "bytestring"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "A UTF-8 encoded string with Bytes as a storage"
|
description = "A UTF-8 encoded string with Bytes as a storage"
|
||||||
keywords = ["actix"]
|
keywords = ["actix"]
|
||||||
|
@ -45,7 +45,7 @@ impl PartialEq<str> for ByteString {
|
|||||||
|
|
||||||
impl hash::Hash for ByteString {
|
impl hash::Hash for ByteString {
|
||||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||||
self.0.hash(state);
|
(**self).hash(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +144,19 @@ impl fmt::Display for ByteString {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
use std::hash::{Hash, Hasher};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_hash() {
|
||||||
|
let mut hasher1 = DefaultHasher::default();
|
||||||
|
"str".hash(&mut hasher1);
|
||||||
|
|
||||||
|
let mut hasher2 = DefaultHasher::default();
|
||||||
|
let s = ByteString::from_static("str");
|
||||||
|
s.hash(&mut hasher2);
|
||||||
|
assert_eq!(hasher1.finish(), hasher2.finish());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_string() {
|
fn test_from_string() {
|
||||||
|
Loading…
Reference in New Issue
Block a user