Skip to content

chore: Use ConstOne/Zero wherever possible - #135

Merged
EmilyMatt merged 2 commits into
mainfrom
const-one
Sep 17, 2026
Merged

EmilyMatt merged 2 commits into
mainfrom
const-one

Conversation

@EmilyMatt

@EmilyMatt EmilyMatt commented Sep 17, 2026 •

Copy link
Copy Markdown
Owner

Ensures compilation-time constants

Summary by CodeRabbit

  • Compatibility

    • Updated numeric algorithm APIs to use compile-time zero and one values.
    • Public functions now require additional numeric capabilities for supported types.
  • Bug Fixes

    • Preserved existing behavior across distance calculations, line drawing, point-cloud processing, polygon hull generation, isometry handling, and rotation validation while improving compatibility with modern numeric types.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: f898a169-ce3f-4a59-b1ac-77faf09db98f

📥 Commits

Reviewing files that changed from the base of the PR and between 59d544d and 5afd260.

📒 Files selected for processing (9)
  • crates/mapping-algorithms/src/geo/haversine.rs
  • crates/mapping-algorithms/src/lines/bresenham.rs
  • crates/mapping-algorithms/src/point_clouds/icp/helpers.rs
  • crates/mapping-algorithms/src/point_clouds/icp/mod.rs
  • crates/mapping-algorithms/src/point_clouds/mod.rs
  • crates/mapping-algorithms/src/polygons/graham_scan.rs
  • crates/mapping-algorithms/src/polygons/jarvis_march.rs
  • crates/mapping-algorithms/src/types/isometry.rs
  • crates/mapping-algorithms/src/utils/mod.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The pull request migrates numeric zero and one construction to ConstZero and ConstOne associated constants. It updates generic bounds and arithmetic across geometry, line, point-cloud, polygon, isometry, and rotation-matrix code.

Changes

Const Trait Migration

Layer / File(s) Summary
Scalar arithmetic updates
crates/mapping-algorithms/src/geo/haversine.rs, crates/mapping-algorithms/src/lines/bresenham.rs
Haversine and Bresenham code use T::ONE, F::ONE, and F::ZERO. Their generic bounds include the required const traits.
Point-cloud zero constants
crates/mapping-algorithms/src/point_clouds/...
Point-cloud center and ICP code replace Zero with ConstZero and use associated zero constants.
Polygon determinant constants
crates/mapping-algorithms/src/polygons/graham_scan.rs, crates/mapping-algorithms/src/polygons/jarvis_march.rs
Polygon determinant comparisons use O::ZERO. The related generic bounds include ConstZero.
Matrix constant bounds
crates/mapping-algorithms/src/types/isometry.rs, crates/mapping-algorithms/src/utils/mod.rs
Isometry and rotation-matrix code add ConstOne and ConstZero bounds and use T::ONE and T::ZERO.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 5afd2

The const-trait migration is permitted by the crate’s stated unstable API policy, and no actionable merge risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing runtime one and zero construction with ConstOne and ConstZero constants across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 9 files.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch const-one

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.02%. Comparing base (59d544d) to head (5afd260).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #135   +/-   ##
=======================================
  Coverage   98.02%   98.02%           
=======================================
  Files          17       17           
  Lines        1825     1825           
  Branches     1825     1825           
=======================================
  Hits         1789     1789           
  Misses         28       28           
  Partials        8        8           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@EmilyMatt EmilyMatt changed the title refactor: Use ConstOne wherever possible refactor: Use ConstOne/Zero wherever possible Sep 17, 2026
@EmilyMatt EmilyMatt changed the title refactor: Use ConstOne/Zero wherever possible chore: Use ConstOne/Zero wherever possible Sep 17, 2026
@EmilyMatt
EmilyMatt merged commit 7544978 into main Sep 17, 2026
13 of 15 checks passed
@EmilyMatt
EmilyMatt deleted the const-one branch September 17, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant