-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement range based iteration #297
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR @Dr-Emann,
I see that this PR is mostly the same as #298. Can you rebase on main once #299 is merged, please?
However, you propose interesting open questions that I will try to answer here.
The equivalent to
.iter_range
forBTreeSet
is called.range()
(and so does #290). Is that a better name:.range/.iter_range
? We also need an owning version,into_range
vsinto_iter_range
?
I indeed prefer that we use the range
naming instead of the iter_range
. This way, as you propose, we will be closer to the standard naming. I also think that, at some point, we will want to support extracting ranges but we will probably name this method extract_range
.
.range
onBTreeSet
panics onstart > end
. (orstart == end
when both are excluded). Should we?
Yes, I think a range with a start > end
is not expected and most likely an error. We should panic. Same for the start == end
case.
Hmm, the current utility to to an inclusive range can't currently differentiate |
Can we do it by hand then? If we cannot then, I think, it's better to just accept them as we don't want to panic for valid empty ranges. |
03682b5
to
d6ad8c4
Compare
@Kerollmops Looks like another dependency update broke the MSRV. |
d6ad8c4
to
8cf9bda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, still some formating issue 😞
Implement `bitmap.iter_range()` and `bitmap.into_iter_range()`, based on `advance_to()` and `advance_back_to()`. Co-authored-by: Matthew Herzl <matthew@herzl.email>
8cf9bda
to
50eda41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect to me, thank you very much for the hard work and patience 🐢
/// Convert a `RangeBounds<u32>` object to `RangeInclusive<u32>`, | ||
pub fn convert_range_to_inclusive<R>(range: R) -> Option<RangeInclusive<u32>> | ||
pub fn convert_range_to_inclusive<R>(range: R) -> Result<RangeInclusive<u32>, ConvertRangeError> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed the code is not pretty but it is very useful, thank you 😊
Implement
bitmap.iter_range()
andbitmap.into_iter_range()
, based onadvance_to()
andadvance_back_to()
. Closes #290.Open questions:
The equivalent toUsing the names.iter_range
forBTreeSet
is called.range()
(and so does Add range-based iteration #290). Is that a better name:.range
/.iter_range
? We also need an owning version,into_range
vsinto_iter_range
?range
/into_range
.Decided to panic on ranges to match BTreeSet. The code is less pretty having to differentiate between validly empty ranges vs invalid ranges, but probably worth it..range
onBTreeSet
panics on start > end. (or start == end when both are excluded). Should we?