-
Notifications
You must be signed in to change notification settings - Fork 199
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
CoordinatesIter
does not implement ExactSizeIterator
correctly, panics
#762
Comments
Hi, could you provide a complete failing test case? |
Sure thing, here you go, this panics: use geo::{Coordinate, LineString};
fn main() {
let ls = LineString(vec![
Coordinate { x: 0., y: 0. },
Coordinate { x: 10., y: 0. },
]);
// reference to force the `impl IntoIterator for &LineString` impl, giving a `CoordinatesIter`
for c in (&ls).into_iter().rev().skip(1).rev() {
println!("{:?}", c);
}
} |
Thanks, just wanted to make sure I wasn't misunderstanding. |
2 tasks
urschrei
added a commit
to urschrei/geo
that referenced
this issue
Mar 12, 2022
2 tasks
bors bot
added a commit
that referenced
this issue
Mar 12, 2022
766: Add missing size_hint method on LineString iterators r=michaelkirk a=urschrei Fixes #762 - [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md). - [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users. --- Co-authored-by: Stephan Hügel <shugel@tcd.ie>
urschrei
added a commit
to urschrei/geo
that referenced
this issue
Mar 13, 2022
bors bot
added a commit
that referenced
this issue
Mar 13, 2022
767: Add ExactsizeIterator impl for Point iterator on LineString r=urschrei a=urschrei - [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md). - [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users. --- Follow-up to #762 and #766 Co-authored-by: Stephan Hügel <shugel@tcd.ie>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comes from the rust discord server, where someone tried to iterate over all but the last point of a LineString (being the exterior of a Polygon). In the meantime we realized just skipping the first one works just as fine for their usecase, but before that we stumbled upon this panic:
From https://doc.rust-lang.org/std/iter/trait.ExactSizeIterator.html:
This means that something like
panics, failing this assertion: https://doc.rust-lang.org/src/core/iter/traits/exact_size.rs.html#103-108
(It would also be nice for
PointsIter
to implementExactSizeIterator
as well I think :P)I haven't looked at other iterators in the crate, but they might also have this issue.
The text was updated successfully, but these errors were encountered: