]>
git.proxmox.com Git - rustc.git/blob - library/alloc/tests/lib.rs
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_intrinsic_copy)]
11 #![feature(const_mut_refs)]
12 #![feature(const_nonnull_slice_from_raw_parts)]
13 #![feature(const_ptr_write)]
14 #![feature(const_try)]
15 #![feature(core_intrinsics)]
16 #![feature(drain_filter)]
17 #![feature(exact_size_is_empty)]
18 #![feature(new_uninit)]
20 #![feature(trusted_len)]
21 #![feature(try_reserve_kind)]
22 #![feature(unboxed_closures)]
23 #![feature(associated_type_bounds)]
24 #![feature(binary_heap_into_iter_sorted)]
25 #![feature(binary_heap_drain_sorted)]
26 #![feature(slice_ptr_get)]
27 #![feature(binary_heap_retain)]
28 #![feature(binary_heap_as_slice)]
29 #![feature(inplace_iteration)]
30 #![feature(iter_advance_by)]
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)]
42 use std
::collections
::hash_map
::DefaultHasher
;
43 use std
::hash
::{Hash, Hasher}
;
62 fn hash
<T
: Hash
>(t
: &T
) -> u64 {
63 let mut s
= DefaultHasher
::new();
68 // FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten.
69 // See https://github.com/kripken/emscripten-fastcomp/issues/169
70 #[cfg(not(target_os = "emscripten"))]
72 fn test_boxed_hasher() {
73 let ordinary_hash
= hash(&5u32);
75 let mut hasher_1
= Box
::new(DefaultHasher
::new());
76 5u32.hash(&mut hasher_1
);
77 assert_eq
!(ordinary_hash
, hasher_1
.finish());
79 let mut hasher_2
= Box
::new(DefaultHasher
::new()) as Box
<dyn Hasher
>;
80 5u32.hash(&mut hasher_2
);
81 assert_eq
!(ordinary_hash
, hasher_2
.finish());