Skip to content
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

[traits] rename CoordTrait::nth_unchecked -> nth_or_panic to match conventional semantics #1242

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

michaelkirk
Copy link
Member

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

unchecked implies it's an unsafe method, like Vec::get_unsafe. It's how we use the term elsewhere in this api, e.g. see this discussion georust/geojson#245 (comment)

I also cleaned up some stale docs.

I opted not to add foo_or_panic methods to the various collections in this PR, as it seemed like a slightly different issue that could be followed up separately.

@michaelkirk michaelkirk force-pushed the mkirk/trait-coord-nth-or-panic branch from a080163 to bc5815e Compare October 30, 2024 18:53
@michaelkirk michaelkirk marked this pull request as ready for review October 30, 2024 18:53
Copy link
Member

@kylebarron kylebarron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there also be an actually unsafe nth_unchecked that doesn't even do a bounds check? (I don't know; I don't usually use any unchecked variants)

@michaelkirk
Copy link
Member Author

I've restored nth_unchecked, marked it unsafe and by default it just calls nth_or_panic.

Please take another look.

///
/// See also [`nth_or_panic()`](Self::nth_or_panic) and [`nth_unchecked()`](Self::nth_unchecked).
///
/// # Panics
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a panic condition.

@michaelkirk michaelkirk enabled auto-merge October 30, 2024 20:15
@michaelkirk michaelkirk force-pushed the mkirk/trait-coord-nth-or-panic branch from 20a6db5 to d6d357d Compare October 30, 2024 22:53
…nventional semantics

`unchecked` implies it's an unsafe method, like `Vec::get_unsafe`

Also cleaned up some stale docs.
@michaelkirk michaelkirk force-pushed the mkirk/trait-coord-nth-or-panic branch from d6d357d to 8fa9776 Compare October 30, 2024 22:53
@michaelkirk michaelkirk added this pull request to the merge queue Oct 30, 2024
Merged via the queue into main with commit ba1cf70 Oct 30, 2024
18 checks passed
@michaelkirk michaelkirk deleted the mkirk/trait-coord-nth-or-panic branch October 30, 2024 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants