12
12
use std:: char;
13
13
use std:: str:: { self , FromStr } ;
14
14
use std:: cmp:: Ordering ;
15
- use std:: hash:: Hash ;
15
+ use std:: hash:: { Hash , Hasher } ;
16
16
use std:: collections:: hash_map:: DefaultHasher ;
17
17
#[ allow( deprecated, unused) ]
18
18
use std:: ascii:: AsciiExt ;
@@ -82,17 +82,22 @@ const EDGES_AND_BETWEEN: [u32;19] = [
82
82
] ;
83
83
84
84
fn eq_cmp_hash ( c : char ) -> ( Utf8Char , Utf16Char ) {
85
- let sh = & mut DefaultHasher :: new ( ) ;
85
+ fn hash < T : Hash > ( v : T ) -> u64 {
86
+ #[ allow( deprecated) ]
87
+ let mut hasher = DefaultHasher :: new ( ) ;
88
+ v. hash ( & mut hasher) ;
89
+ hasher. finish ( )
90
+ }
86
91
let u8c = c. to_utf8 ( ) ;
87
92
assert_eq ! ( u8c. to_char( ) , c) ;
88
93
assert_eq ! ( u8c, u8c) ;
89
- assert_eq ! ( u8c . hash( sh ) , c . hash( sh ) ) ;
94
+ assert_eq ! ( hash( u8c ) , hash( u8c ) ) ;
90
95
assert_eq ! ( u8c. cmp( & u8c) , Ordering :: Equal ) ;
91
96
assert ! ( u8c. eq_ignore_ascii_case( & u8c) ) ;
92
97
let u16c = c. to_utf16 ( ) ;
93
98
assert_eq ! ( u16c. to_char( ) , c) ;
94
99
assert_eq ! ( u16c, u16c) ;
95
- assert_eq ! ( u16c . hash( sh ) , c . hash( sh ) ) ;
100
+ assert_eq ! ( hash( u16c ) , hash( c ) ) ;
96
101
assert_eq ! ( u16c. cmp( & u16c) , Ordering :: Equal ) ;
97
102
assert ! ( u16c. eq_ignore_ascii_case( & u16c) ) ;
98
103
@@ -101,13 +106,13 @@ fn eq_cmp_hash(c: char) -> (Utf8Char, Utf16Char) {
101
106
102
107
let u8other = other. to_utf8 ( ) ;
103
108
assert_eq ! ( u8c == u8other, c == other) ;
104
- assert_eq ! ( u8c . hash( sh ) ==other . hash( sh ) , c . hash( sh ) ==u8other . hash( sh ) ) ;
109
+ assert_eq ! ( hash( u8c ) ==hash( u8other ) , hash( c ) ==hash( other ) ) ;
105
110
assert_eq ! ( u8c. cmp( & u8other) , c. cmp( & other) ) ;
106
111
assert_eq ! ( u8c. eq_ignore_ascii_case( & u8other) , c. eq_ignore_ascii_case( & other) ) ;
107
112
108
113
let u16other = other. to_utf16 ( ) ;
109
114
assert_eq ! ( u16c == u16other, c == other) ;
110
- assert_eq ! ( u16c . hash( sh ) ==other . hash( sh ) , c . hash( sh ) ==u16other . hash( sh ) ) ;
115
+ assert_eq ! ( hash( u16c ) ==hash( u16other ) , hash( c ) ==hash( other ) ) ;
111
116
assert_eq ! ( u16c. cmp( & u16other) , c. cmp( & other) ) ;
112
117
assert_eq ! ( u16c. eq_ignore_ascii_case( & u16other) , c. eq_ignore_ascii_case( & other) ) ;
113
118
}
0 commit comments