Skip to content

feat(api): add common Delaunay result alias - #470

Merged
acgetchell merged 1 commit into
mainfrom
feat/delaunay-result-alias
Jun 19, 2026
Merged

feat(api): add common Delaunay result alias#470
acgetchell merged 1 commit into
mainfrom
feat/delaunay-result-alias

Conversation

@acgetchell

Copy link
Copy Markdown
Owner
  • Add DelaunayError and DelaunayResult for common construction, insertion, validation, coordinate conversion, and toroidal-domain setup workflows.
  • Re-export the aliases from the crate root and construction preludes for downstream examples and applications.
  • Update public docs and examples to use DelaunayResult when workflow-specific errors are not required.

- Add DelaunayError and DelaunayResult for common construction, insertion, validation, coordinate conversion, and toroidal-domain setup workflows.
- Re-export the aliases from the crate root and construction preludes for downstream examples and applications.
- Update public docs and examples to use DelaunayResult when workflow-specific errors are not required.
@acgetchell acgetchell self-assigned this Jun 19, 2026
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Introduces DelaunayError (a thiserror enum consolidating construction, coordinate conversion, insertion, validation, and toroidal-domain failures) and DelaunayResult<T> in construction.rs, re-exports both at the crate root and preludes, and standardizes all Rust doc examples and markdown code snippets to use DelaunayResult<()> instead of per-example thiserror enums.

Changes

DelaunayError API and example standardization

Layer / File(s) Summary
DelaunayError enum, DelaunayResult alias, and crate re-exports
src/delaunay/construction.rs, src/lib.rs
Defines pub enum DelaunayError with #[from] variants for all construction-related failure modes, adds pub type DelaunayResult<T>, reorganizes module imports, and re-exports both types from the crate root, prelude, and prelude::construction.
Integration tests for DelaunayError aliases and trait bounds
tests/prelude_exports.rs, src/lib.rs
Adds slotmap::KeyData import, RootDelaunayError/RootDelaunayResult aliases, a new test that constructs all six DelaunayError variants and asserts correct mapping into RootDelaunayError, a Send+Sync+Unpin assertion for DelaunayError, and a is_normal assertion in normal_types.
Rustdoc example updates in source files
src/delaunay/construction.rs, src/delaunay/builder.rs, src/delaunay/insertion.rs, src/delaunay/triangulation.rs, src/delaunay/validation.rs, src/lib.rs
Replaces ExampleError-based Result wrappers and their associated thiserror imports with DelaunayResult<()> return types in all rustdoc main harnesses across the listed source files.
Markdown documentation example updates
README.md, docs/api_design.md, docs/diagnostics.md, docs/validation.md, docs/workflows.md, docs/dev/tooling-alignment.md
Rewrites code snippet imports and main signatures in all affected markdown docs to use DelaunayResult<()>, removes custom thiserror enums from examples, and updates the developer guidance to require DelaunayResult<()> for examples whose errors are covered by DelaunayError.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • acgetchell/delaunay#392: Both PRs modify src/lib.rs prelude wiring; the retrieved PR refactors prelude facades for crate::core APIs, overlapping with this PR's addition of DelaunayError/DelaunayResult to those same re-export lists.
  • acgetchell/delaunay#409: Both PRs update the same markdown and doc examples (README.md, docs/*) to use a Result-returning main; this PR standardizes that pattern on DelaunayResult<()>.
  • acgetchell/delaunay#464: Both PRs modify src/delaunay/construction.rs and associated doc examples around fallible construction error handling; the retrieved PR introduces try_* constructor names in the same area this PR introduces DelaunayError/DelaunayResult.

Suggested labels

api, enhancement, rust

🐇 A rabbit once juggled errors galore,
ExampleError enums, a dozen or more!
Now DelaunayResult wraps them up neat,
One type to return, clean and petite.
No more boilerplate—just build and move on,
The warren rejoices, the clutter is gone! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 83.33% which is insufficient. The required threshold is 100.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(api): add common Delaunay result alias' directly describes the main change—introducing new type aliases (DelaunayError and DelaunayResult) for common Delaunay workflows.
Description check ✅ Passed The description clearly outlines the three main objectives: adding DelaunayError and DelaunayResult aliases, re-exporting them, and updating documentation/examples to use them.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/delaunay-result-alias

Comment @coderabbitai help to get the list of available commands and usage tips.

@acgetchell
acgetchell enabled auto-merge (squash) June 19, 2026 04:19
@codacy-production

codacy-production Bot commented Jun 19, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 8 complexity

Metric Results
Complexity 8

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.02% coverage variation

Metric Results
Coverage variation +0.02% coverage variation (-1.00%)
Diff coverage 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (b80d25a) 69016 63269 91.67%
Head commit (98cc81e) 69017 (+1) 63281 (+12) 91.69% (+0.02%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#470) 1 1 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.66%. Comparing base (b80d25a) to head (98cc81e).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #470      +/-   ##
==========================================
+ Coverage   91.64%   91.66%   +0.01%     
==========================================
  Files          72       72              
  Lines       68796    68796              
==========================================
+ Hits        63051    63062      +11     
+ Misses       5745     5734      -11     
Flag Coverage Δ
unittests 91.66% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@acgetchell

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot added api enhancement New feature or request rust Pull requests that update rust code labels Jun 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/diagnostics.md (1)

71-87: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use the Result API here instead of is_valid().

validation_report() returns Result<(), TriangulationValidationReport>, so report.is_valid() will not compile in the doctest.

Suggested fix
-    let report = dt.validation_report();
-    assert!(report.is_valid());
+    assert!(dt.validation_report().is_ok());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/diagnostics.md` around lines 71 - 87, The validation_report() method
returns a Result type, not a value with an is_valid() method, so the current
code will not compile. Replace the call to report.is_valid() with the
appropriate Result API method report.is_ok() to properly check if the validation
was successful, keeping it consistent with the validate() check performed
earlier in the code.
🧹 Nitpick comments (2)
src/delaunay/validation.rs (1)

723-759: ⚡ Quick win

Update the remaining doctest wrapper here.

This example still uses ExampleError/thiserror, so validation.rs is only partially aligned with the new DelaunayResult pattern. Based on the PR objective to standardize examples on DelaunayResult.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/delaunay/validation.rs` around lines 723 - 759, The doctest example in
this documentation comment still uses a custom ExampleError enum with thiserror
instead of the standardized DelaunayResult pattern. Replace the custom
ExampleError enum definition and change the main function signature to return
DelaunayResult instead of Result<(), ExampleError>, then remove the individual
error variant definitions for Construction, Serde, Validation, and Coordinate
errors since DelaunayResult should handle all these error types automatically.
src/delaunay/builder.rs (1)

1149-1250: ⚡ Quick win

Finish the DelaunayResult migration here.

These later doctests still define ExampleError with thiserror, so the builder docs are mixing two example styles. Based on the PR objective to standardize examples on DelaunayResult.

Also applies to: 1491-1527

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/delaunay/builder.rs` around lines 1149 - 1250, The doctests in
try_from_vertices_and_simplices and try_from_vertices_and_simplices_generic
methods are still using the custom ExampleError enum with thiserror, which
conflicts with the PR's goal to standardize on DelaunayResult. Replace the
ExampleError enum definitions and main function signatures in both doctests to
use DelaunayResult instead, removing the need for the custom error wrapper.
Update the error handling patterns accordingly to align with the DelaunayResult
style used elsewhere in the documentation, and apply the same migration pattern
to any additional doctests in the 1491-1527 range mentioned in the comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@docs/diagnostics.md`:
- Around line 71-87: The validation_report() method returns a Result type, not a
value with an is_valid() method, so the current code will not compile. Replace
the call to report.is_valid() with the appropriate Result API method
report.is_ok() to properly check if the validation was successful, keeping it
consistent with the validate() check performed earlier in the code.

---

Nitpick comments:
In `@src/delaunay/builder.rs`:
- Around line 1149-1250: The doctests in try_from_vertices_and_simplices and
try_from_vertices_and_simplices_generic methods are still using the custom
ExampleError enum with thiserror, which conflicts with the PR's goal to
standardize on DelaunayResult. Replace the ExampleError enum definitions and
main function signatures in both doctests to use DelaunayResult instead,
removing the need for the custom error wrapper. Update the error handling
patterns accordingly to align with the DelaunayResult style used elsewhere in
the documentation, and apply the same migration pattern to any additional
doctests in the 1491-1527 range mentioned in the comment.

In `@src/delaunay/validation.rs`:
- Around line 723-759: The doctest example in this documentation comment still
uses a custom ExampleError enum with thiserror instead of the standardized
DelaunayResult pattern. Replace the custom ExampleError enum definition and
change the main function signature to return DelaunayResult instead of
Result<(), ExampleError>, then remove the individual error variant definitions
for Construction, Serde, Validation, and Coordinate errors since DelaunayResult
should handle all these error types automatically.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: c3883b65-93f4-469c-be75-83ea11e17651

📥 Commits

Reviewing files that changed from the base of the PR and between b80d25a and 98cc81e.

📒 Files selected for processing (13)
  • README.md
  • docs/api_design.md
  • docs/dev/tooling-alignment.md
  • docs/diagnostics.md
  • docs/validation.md
  • docs/workflows.md
  • src/delaunay/builder.rs
  • src/delaunay/construction.rs
  • src/delaunay/insertion.rs
  • src/delaunay/triangulation.rs
  • src/delaunay/validation.rs
  • src/lib.rs
  • tests/prelude_exports.rs

@acgetchell
acgetchell merged commit db46fa2 into main Jun 19, 2026
22 checks passed
@acgetchell
acgetchell deleted the feat/delaunay-result-alias branch June 19, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api enhancement New feature or request rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant