Skip to content

docs: prefer fallible construction in public examples#25

Merged
blackopsrepl merged 1 commit intomainfrom
issue/12-docs-prefer-fallible-construction
Mar 21, 2026
Merged

docs: prefer fallible construction in public examples#25
blackopsrepl merged 1 commit intomainfrom
issue/12-docs-prefer-fallible-construction

Conversation

@blackopsrepl
Copy link
Copy Markdown
Contributor

Summary

  • update public docs and examples to prefer try_new for user-provided coordinates and bounds
  • keep panic-free examples aligned across the crate docs and README
  • preserve guidance that infallible constructors are still fine for trusted literals

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --doc
  • cargo test

Fixes #12

@blackopsrepl blackopsrepl merged commit 3b828f9 into main Mar 21, 2026
3 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4304dd1f03

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Valid ranges: lat [-90, 90], lng [-180, 180]
let coord = Coord::try_new(39.95, -75.16).unwrap();
// Coord::new is still fine for trusted literals that are guaranteed valid
let trusted_coord = Coord::new(39.95, -75.16);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Rebind coord to a Coord before the later example calls

Replacing the old let coord = Coord::try_new(...).unwrap(); with let trusted_coord = Coord::new(...) leaves coord bound to the Result<Coord, CoordError> from a few lines above. The subsequent coord.distance_to(other) and coord.into() therefore no longer type-check, so the public Coord example in the README regressed from copy-pastable to uncompilable.

Useful? React with 👍 / 👎.

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.

docs: prefer fallible construction patterns in public examples

1 participant