jonhoo / ordsearch

A Rust data structure for efficient lower-bound lookups

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typo?

alisa101rs opened this issue · comments

Hi! I've been watching your open source maintenance stream, and noticed you've been talking about diving numbers by 256.
But this code does not do it:

if duplicates {
let r = (r % size) / 16 * 16;
let r = std::cmp::min(r, MAX);
*e = T::try_from(r).unwrap();
} else {

I think there are rarely cases when we want to divide and multiple by the same number and there are certainly none for usizes (unless the dividend is smaller then 16, but I think in that case it would've been better to express it more explicitly).
Not sure if that's important or not, just wanted to point that out.

Ah, I thought we already fixed that, but apparently not in all the cases:

T::try_from(int % 256).unwrap()

In reality this should probably be % 256 the same way we've done for ^. Would you want to submit a PR?
cc @bazhenov @Qqwy who have been doing a lot of the heavy lifting in this crate recently 💪