1 #![feature(allocator_api)]
2 #![feature(alloc_layout_extra)]
3 #![feature(assert_matches)]
4 #![feature(box_syntax)]
5 #![feature(cow_is_borrowed)]
7 #![feature(const_convert)]
8 #![feature(const_cow_is_borrowed)]
9 #![feature(const_heap)]
10 #![feature(const_mut_refs)]
11 #![feature(const_nonnull_slice_from_raw_parts)]
12 #![feature(const_ptr_write)]
13 #![feature(const_try)]
14 #![feature(core_intrinsics)]
15 #![feature(drain_filter)]
16 #![feature(exact_size_is_empty)]
17 #![feature(new_uninit)]
19 #![feature(trusted_len)]
20 #![feature(try_reserve_kind)]
21 #![feature(unboxed_closures)]
22 #![feature(associated_type_bounds)]
23 #![feature(binary_heap_into_iter_sorted)]
24 #![feature(binary_heap_drain_sorted)]
25 #![feature(slice_ptr_get)]
26 #![feature(binary_heap_retain)]
27 #![feature(binary_heap_as_slice)]
28 #![feature(inplace_iteration)]
29 #![feature(iter_advance_by)]
30 #![feature(iter_next_chunk)]
31 #![feature(round_char_boundary)]
32 #![feature(slice_group_by)]
33 #![feature(slice_partition_dedup)]
34 #![feature(string_remove_matches)]
35 #![feature(const_btree_new)]
36 #![feature(const_default_impls)]
37 #![feature(const_trait_impl)]
38 #![feature(const_str_from_utf8)]
39 #![feature(nonnull_slice_from_raw_parts)]
40 #![feature(panic_update_hook)]
41 #![feature(pointer_is_aligned)]
42 #![feature(slice_flatten)]
44 #![feature(bench_black_box)]
45 #![feature(strict_provenance)]
46 #![feature(once_cell)]
48 use std::collections::hash_map::DefaultHasher;
49 use std::hash::{Hash, Hasher};
69 fn hash<T: Hash>(t: &T) -> u64 {
70 let mut s = DefaultHasher::new();
75 // FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten.
76 // See https://github.com/kripken/emscripten-fastcomp/issues/169
77 #[cfg(not(target_os = "emscripten"))]
79 fn test_boxed_hasher() {
80 let ordinary_hash = hash(&5u32);
82 let mut hasher_1 = Box::new(DefaultHasher::new());
83 5u32.hash(&mut hasher_1);
84 assert_eq!(ordinary_hash, hasher_1.finish());
86 let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<dyn Hasher>;
87 5u32.hash(&mut hasher_2);
88 assert_eq!(ordinary_hash, hasher_2.finish());