]> git.proxmox.com Git - rustc.git/blame - library/alloc/tests/lib.rs
New upstream version 1.47.0+dfsg1
[rustc.git] / library / alloc / tests / lib.rs
CommitLineData
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 18use std::collections::hash_map::DefaultHasher;
dfeec247 19use std::hash::{Hash, Hasher};
e9174d1e 20
8faf50e0 21mod arc;
c34b1796 22mod binary_heap;
f9f354fc 23mod borrow;
e74abb32 24mod boxed;
3dfed10e 25mod btree_set_hash;
c30ab7b3 26mod cow_str;
c34b1796 27mod fmt;
ff7c6d11 28mod heap;
c34b1796 29mod linked_list;
8faf50e0 30mod rc;
c34b1796
AL
31mod slice;
32mod str;
33mod string;
c34b1796 34mod vec;
dfeec247 35mod vec_deque;
e9174d1e
SL
36
37fn 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]
47fn 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}