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