docs: prefer fallible construction in public examples#25
Conversation
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
try_newfor user-provided coordinates and boundsValidation
Fixes #12