]>
Commit | Line | Data |
---|---|---|
ff7c6d11 | 1 | #![feature(allocator_api)] |
c34b1796 | 2 | #![feature(box_syntax)] |
3b2f2976 | 3 | #![feature(drain_filter)] |
476ff2be | 4 | #![feature(exact_size_is_empty)] |
e74abb32 | 5 | #![feature(new_uninit)] |
62682a34 | 6 | #![feature(pattern)] |
3dfed10e | 7 | #![feature(str_split_once)] |
416331ca | 8 | #![feature(trusted_len)] |
0531ce1d | 9 | #![feature(try_reserve)] |
c34b1796 | 10 | #![feature(unboxed_closures)] |
416331ca | 11 | #![feature(associated_type_bounds)] |
e74abb32 XL |
12 | #![feature(binary_heap_into_iter_sorted)] |
13 | #![feature(binary_heap_drain_sorted)] | |
3dfed10e | 14 | #![feature(slice_ptr_get)] |
74b04a01 | 15 | #![feature(split_inclusive)] |
f9f354fc | 16 | #![feature(binary_heap_retain)] |
c1a9b12d | 17 | |
9e0c209e | 18 | use std::collections::hash_map::DefaultHasher; |
dfeec247 | 19 | use std::hash::{Hash, Hasher}; |
e9174d1e | 20 | |
8faf50e0 | 21 | mod arc; |
c34b1796 | 22 | mod binary_heap; |
f9f354fc | 23 | mod borrow; |
e74abb32 | 24 | mod boxed; |
3dfed10e | 25 | mod btree_set_hash; |
c30ab7b3 | 26 | mod cow_str; |
c34b1796 | 27 | mod fmt; |
ff7c6d11 | 28 | mod heap; |
c34b1796 | 29 | mod linked_list; |
8faf50e0 | 30 | mod rc; |
c34b1796 AL |
31 | mod slice; |
32 | mod str; | |
33 | mod string; | |
c34b1796 | 34 | mod vec; |
dfeec247 | 35 | mod vec_deque; |
e9174d1e SL |
36 | |
37 | fn hash<T: Hash>(t: &T) -> u64 { | |
9e0c209e | 38 | let mut s = DefaultHasher::new(); |
e9174d1e SL |
39 | t.hash(&mut s); |
40 | s.finish() | |
41 | } | |
ea8adc8c XL |
42 | |
43 | // FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten. | |
44 | // See https://github.com/kripken/emscripten-fastcomp/issues/169 | |
45 | #[cfg(not(target_os = "emscripten"))] | |
46 | #[test] | |
47 | fn test_boxed_hasher() { | |
48 | let ordinary_hash = hash(&5u32); | |
49 | ||
50 | let mut hasher_1 = Box::new(DefaultHasher::new()); | |
51 | 5u32.hash(&mut hasher_1); | |
52 | assert_eq!(ordinary_hash, hasher_1.finish()); | |
53 | ||
8faf50e0 | 54 | let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<dyn Hasher>; |
ea8adc8c XL |
55 | 5u32.hash(&mut hasher_2); |
56 | assert_eq!(ordinary_hash, hasher_2.finish()); | |
57 | } |