File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ struct BitArray
35
35
def == (other : BitArray )
36
36
return false if size != other.size
37
37
# NOTE: If BitArray implements resizing, there may be more than 1 binary
38
- # representation for equivalent BitArrays after a downsize as the discarded
39
- # bits may not have been zeroed.
38
+ # representation and their hashes for equivalent BitArrays after a downsize as the
39
+ # discarded bits may not have been zeroed.
40
40
return LibC .memcmp(@bits , other.@bits , malloc_size) == 0
41
41
end
42
42
@@ -226,6 +226,13 @@ struct BitArray
226
226
Slice .new(@bits .as(Pointer (UInt8 )), (@size / 8.0 ).ceil.to_i)
227
227
end
228
228
229
+ # See `Object#hash(hasher)`
230
+ def hash (hasher )
231
+ hasher = size.hash(hasher)
232
+ hasher = to_slice.hash(hasher)
233
+ hasher
234
+ end
235
+
229
236
private def bit_index_and_sub_index (index )
230
237
bit_index_and_sub_index(index) { raise IndexError .new }
231
238
end
You can’t perform that action at this time.
0 commit comments