Josh Stone
Josh Stone
Please see https://crates.io/crates/ringmap
You can already do this with `extract_if`, because dropping the iterator will keep the remainder. ```rust let mut removed = 0; for _ in map.extract_if(|&k, _| k % 2 !=...
I suppose a limitation compared to your proposal is that you can only stop `extract_if` on the boundary of an extracted item, after each `Iterator::next()`. So `extract_if` can't shortcut something...
As a workaround, you could extract that final item to terminate the loop, and then re-insert it. Even with rehashing, that may be faster than continuing to iterate the rest...
I don't love the name `filter`, but I don't have a good suggestion right now. Otherwise, the shape of this seems pretty good. Ultimately @Amanieu should decide on new `hashbrown`...
That print is an observable side effect -- the compiler **cannot** skip that by optimization.
The values of `counter` and `counter_true` can't be changed by optimization either. The way to think about this is to see what the behavior would be without any optimization, and...
I'm also not trying to dismiss your case, just offering a reason why we _might_ not address it. Sometimes the answer can be "no" for other reasons too, like maintenance...
There's also the fun fact that `counter += 1` can in theory wrap around, so in the optimizer's eyes that may not always remain `>=3`. I tried `counter = counter.saturating_add(1)`...
The internal layout of`BigDigit`s is an implementation detail, and I don't see how we could support arbitrary slices without exposing that. Plus, duplicating all ops on these ref types would...