-
Notifications
You must be signed in to change notification settings - Fork 491
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
Fix bug in Rect::contains, clarify docs, and add doctests for it. #635
Conversation
Hmm, looks like the doctest for a 0-by-0 rect is failing, because apparently, |
Before merging this I'd like to know what will be affected by this, and if this effectively counts as a bugfix or if this is only a sneaky breaking change. Fixing this bug is fine, but if we end up with other bugs because they thought this version of Makes me think about the famous "YOU DO NOT BREAK USERSPACE" from Torvalds. There was the same kind of unintended behavior with memcpy and copy to overlapped memory. After they fixed that, flash users experienced problems. They had two choices: let the developers fix their usage of memcpy, or not make such a breaking change sneakily. We're in the exact same case, and just because we know that we won't be affected by this change because we know about it, doesn't mean everyone's like that. I'd prefer if this function was deprecated, and we used a rename as the "correct" way of doing things. |
Well...it seems like a bug to me (given that the current behavior differs from So I propose marking Update on the way. |
/// assert!(rect.contains(Point::new(4, 6))); // N.B. | ||
/// assert!(!rect.contains(Point::new(5, 7))); | ||
/// ``` | ||
#[deprecated(since = "0.30.0", note = "use `contains_point` instead")] |
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.
Wait ... does this work ? I thought they could only be used internally by the compiler ? Which release of Rust added the deprecated attribute ?
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.
I don't know which commit or release added this but it definitely works with non-compiler internals.
I've used it in quite a few projects.
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.
Great changes ! hanks for the doc tests, it definitely helps ! Just a little change about linking the issue, squash all of that in a single commit and we'll be good to go !
src/sdl2/rect.rs
Outdated
/// [`SDL_PointInRect`](https://wiki.libsdl.org/SDL_PointInRect) by | ||
/// including points along the bottom and right edges of the rectangle, so | ||
/// that a 1-by-1 rectangle actually covers an area of four points, not | ||
/// one. |
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.
Can you please link to issue #569 here ? The notice here is great but it would be even better you there was a link to the original issue / discussion so curious users can see what it is about exactly 😃
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.
Done.
Great, thanks ! Merged. |
This is to fix issue #569.