| 1 | //! A simple hasher that literally just maps an int to itself. |
| 2 | //! |
| 3 | //! Originally based on <https://github.com/tetcoin/nohash/blob/master/src/lib.rs>. |
| 4 | |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 6 | hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::{BuildHasherDefaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasherDefault#, Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#}, |
| 7 | markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 8 | }; |
| 9 | |
| 10 | use indexmaprust-analyzer cargo indexmap 2.14.0 crate/::IndexMaprust-analyzer cargo indexmap 2.14.0 map/IndexMap#; |
| 11 | |
| 12 | type IntHasherStaterust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasherState#<K> = BuildHasherDefaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasherDefault#<IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#<K>>; |
| 13 | |
| 14 | /// A hash map that directly maps from an integer key to a value. |
| 15 | pub type IntHashMaprust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHashMap#<K, V> = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<K, V, IntHasherStaterust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasherState#<K>>; |
| 16 | |
| 17 | /// A hash set that directly uses integer keys. |
| 18 | #[allow(dead_code)] |
| 19 | pub type IntHashSetrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHashSet#<K> = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<K, IntHasherStaterust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasherState#<K>>; |
| 20 | |
| 21 | /// An [`IndexMap`] wrapper such that it tracks insertion order, but uses |
| 22 | /// integer keys. |
| 23 | pub type IntIndexMaprust-analyzer cargo bottom 0.14.9 utils/int_hash/IntIndexMap#<K, V> = IndexMaprust-analyzer cargo indexmap 2.14.0 map/IndexMap#<K, V, IntHasherStaterust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasherState#<K>>; |
| 24 | |
| 25 | pub trait SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# {} |
| 26 | |
| 27 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for u8 {} |
| 28 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for u16 {} |
| 29 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for u32 {} |
| 30 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for u64 {} |
| 31 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for usize {} |
| 32 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for i8 {} |
| 33 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for i16 {} |
| 34 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for i32 {} |
| 35 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for i64 {} |
| 36 | impl SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt# for isize {} |
| 37 | |
| 38 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 39 | pub struct IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#<T: SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt#> { |
| 40 | innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner.: u64, |
| 41 | _markerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#_marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<T>, |
| 42 | } |
| 43 | |
| 44 | impl<T: SupportedIntrust-analyzer cargo bottom 0.14.9 utils/int_hash/SupportedInt#> Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher# for IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#<T> { |
| 45 | fn finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(&self) -> u64 { |
| 46 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. |
| 47 | } |
| 48 | |
| 49 | fn writerust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write().(&mut self, _bytes: &[u8]) { |
| 50 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("IntHasher does not support arbitrary writes") |
| 51 | } |
| 52 | |
| 53 | fn write_u8rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_u8().(&mut self, i: u8) { |
| 54 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i as u64; |
| 55 | } |
| 56 | |
| 57 | fn write_u16rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_u16().(&mut self, i: u16) { |
| 58 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i as u64; |
| 59 | } |
| 60 | |
| 61 | fn write_u32rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_u32().(&mut self, i: u32) { |
| 62 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i as u64; |
| 63 | } |
| 64 | |
| 65 | fn write_u64rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_u64().(&mut self, i: u64) { |
| 66 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i; |
| 67 | } |
| 68 | |
| 69 | fn write_usizerust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_usize().(&mut self, i: usize) { |
| 70 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i as u64; |
| 71 | } |
| 72 | |
| 73 | fn write_i8rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_i8().(&mut self, i: i8) { |
| 74 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i as u64; |
| 75 | } |
| 76 | |
| 77 | fn write_i16rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_i16().(&mut self, i: i16) { |
| 78 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i as u64; |
| 79 | } |
| 80 | |
| 81 | fn write_i32rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_i32().(&mut self, i: i32) { |
| 82 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i as u64; |
| 83 | } |
| 84 | |
| 85 | fn write_i64rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_i64().(&mut self, i: i64) { |
| 86 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i as u64; |
| 87 | } |
| 88 | |
| 89 | fn write_isizerust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_isize().(&mut self, i: isize) { |
| 90 | self.innerrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#inner. = i as u64; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | #[cfg(test)] |
| 95 | mod testsrust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/ { |
| 96 | use superrust-analyzer cargo bottom 0.14.9 utils/int_hash/::*; |
| 97 | |
| 98 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 99 | fn test_u8rust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_u8().() { |
| 100 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<u8>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 101 | hasher.write_u8rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_u8().(42); |
| 102 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), 42); |
| 103 | } |
| 104 | |
| 105 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 106 | fn test_u16rust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_u16().() { |
| 107 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<u16>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 108 | hasher.write_u16rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_u16().(4242); |
| 109 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), 4242); |
| 110 | } |
| 111 | |
| 112 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 113 | fn test_u32rust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_u32().() { |
| 114 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<u32>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 115 | hasher.write_u32rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_u32().(424242); |
| 116 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), 424242); |
| 117 | } |
| 118 | |
| 119 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 120 | fn test_u64rust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_u64().() { |
| 121 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<u64>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 122 | hasher.write_u64rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_u64().(4242424242); |
| 123 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), 4242424242); |
| 124 | } |
| 125 | |
| 126 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 127 | fn test_usizerust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_usize().() { |
| 128 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<usize>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 129 | hasher.write_usizerust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_usize().(999999); |
| 130 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), 999999); |
| 131 | } |
| 132 | |
| 133 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 134 | fn test_i8rust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_i8().() { |
| 135 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<i8>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 136 | hasher.write_i8rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_i8().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().42); |
| 137 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().42_i8 as u64); |
| 138 | } |
| 139 | |
| 140 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 141 | fn test_i16rust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_i16().() { |
| 142 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<i16>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 143 | hasher.write_i16rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_i16().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().4242); |
| 144 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().4242_i64 as u64); |
| 145 | } |
| 146 | |
| 147 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 148 | fn test_i32rust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_i32().() { |
| 149 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<i32>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 150 | hasher.write_i32rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_i32().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().424242); |
| 151 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().424242_i64 as u64); |
| 152 | } |
| 153 | |
| 154 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 155 | fn test_i64rust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_i64().() { |
| 156 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<i64>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 157 | hasher.write_i64rust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_i64().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().4242424242); |
| 158 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().4242424242_i64 as u64); |
| 159 | } |
| 160 | |
| 161 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 162 | fn test_isizerust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_isize().() { |
| 163 | let mut hasher = IntHasherrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHasher#::<isize>::defaultrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Default]default().(); |
| 164 | hasher.write_isizerust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]write_isize().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][Neg]neg().424242); |
| 165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hasher.finishrust-analyzer cargo bottom 0.14.9 utils/int_hash/impl#[`IntHasher<T>`][Hasher]finish().(), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][Neg]neg().424242_isize as u64); |
| 166 | } |
| 167 | |
| 168 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 169 | fn test_int_hash_maprust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_int_hash_map().() { |
| 170 | let mut map = IntHashMaprust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHashMap#::<u32, &str>::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(); |
| 171 | map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(1, "one"); |
| 172 | map.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(2, "two"); |
| 173 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&1), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"one")); |
| 174 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&2), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"two")); |
| 175 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&3), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 176 | } |
| 177 | |
| 178 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 179 | fn test_int_hash_setrust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_int_hash_set().() { |
| 180 | let mut set = IntHashSetrust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHashSet#::<u32>::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][Default]default().(); |
| 181 | set.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(1); |
| 182 | set.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(2); |
| 183 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&1)); |
| 184 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&2)); |
| 185 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().set.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&3)); |
| 186 | } |
| 187 | |
| 188 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 189 | fn test_int_index_maprust-analyzer cargo bottom 0.14.9 utils/int_hash/tests/test_int_index_map().() { |
| 190 | let mut map = IntIndexMaprust-analyzer cargo bottom 0.14.9 utils/int_hash/IntIndexMap#::<u32, &str>::defaultrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][Default]default().(); |
| 191 | map.insertrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]insert().(1, "one"); |
| 192 | map.insertrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]insert().(3, "three"); |
| 193 | map.insertrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]insert().(2, "two"); |
| 194 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map.getrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]get().(&1), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"one")); |
| 195 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map.getrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]get().(&2), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"two")); |
| 196 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map.getrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]get().(&3), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&"three")); |
| 197 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map.getrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]get().(&4), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 198 | |
| 199 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map.keysrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]keys().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 3, 2]); |
| 200 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 201 | map.valuesrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]values().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(), |
| 202 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["one", "three", "two"] |
| 203 | ); |
| 204 | } |
| 205 | } |