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