-
Notifications
You must be signed in to change notification settings - Fork 83
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
Insert/remove range with bounds #115
Insert/remove range with bounds #115
Conversation
Hi @Kerollmops Thanks for your reviewing! Recently I might have no time to code since I'm on my way to travel 👻. But I would come back ASAP. |
Hi @Kerollmops |
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 very much for your changes, can you please change your code a little bit, please?
I think I will merge your code just after :)
Hi @Kerollmops And I just want to mention the pub fn convert_range_to_inclusive<R>(range: R) -> Option<RangeInclusive<u32>>
where
R: RangeBounds<u32>,
{
let start: u32 = match range.start_bound() {
Bound::Included(&i) => i,
Bound::Excluded(&u32::MAX) => return None, // must exit here
Bound::Excluded(&i) => i + 1,
Bound::Unbounded => 0,
};
let end: u32 = match range.end_bound() {
Bound::Included(&i) => i,
Bound::Excluded(&0) => return None, // must exit here
Bound::Excluded(&i) => i - 1,
Bound::Unbounded => u32::MAX,
};
if end < start {
return None;
}
Some(start..=end)
} In this way we can idiomatically avoid the |
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.
It is indeed a lot better @oliverdding, I love what you've done here.
I am merging all of that right now!
Implementation of
insert_range
andremove_range
functions that accept theRangeBounds
trait instead of aRange
struct.This PR fix #5 and #113.
Done:
RangeBounds
insert_range
remove_range
insert_range
/remove_range
RangeInclude
on theContainer
andStore
insert_range
remove_range