-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat: make Level::span generic over RangeBounds #152
Conversation
Bound::Included(e) => Bound::Included(e - new_start), | ||
}; | ||
let range_end = match ann.range.1 { | ||
Bound::Unbounded => Bound::Unbounded, |
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.
Hm, I'm wondering if this needs to be Bound::Exclusive(ann.exclusive_end(foo) - new_start)
instead.
Do you mind if I ask what the reasoning behind this change was? |
Not at all! I tried to use a |
Could you expand on what your use case is? We expect this to be used programmatically which would generally be done with one range type and the current is most flexible. |
There is no use case. This is just an ergonomic upgrade. It allows the following ranges that weren't allowed before: Level::Error.span(2..4); // Range (what you support now)
Level::Error.span(2..=4); // RangeInclusive
Level::Error.span(..4); // RangeTo
Level::Error.span(..=4); // RangeToInclusive
Level::Error.span(2..); // RangeFrom
Level::Error.span(..); // RangeFull If this adds too much complexity, feel free to close. I don't mind. |
What i want to understand from the use case is how you are creating the spans. Are you hand writing them? If so, why? |
I have a lint that always starts from the beginning of a line, which is probably the only decent example I have. |
Without a more specific use case, I am not sure if the added complexity is worth it at this time. I think this is something to look into more as the library progresses. That said, I am going to close this for now, but I greatly appreciate the PR. |
No description provided.