Skip to content

Changed: Use borrowed APIs in utility functions#190

Merged
acgetchell merged 2 commits intomainfrom
refactor/borrow-first-utils
Feb 7, 2026
Merged

Changed: Use borrowed APIs in utility functions#190
acgetchell merged 2 commits intomainfrom
refactor/borrow-first-utils

Conversation

@acgetchell
Copy link
Owner

Updates into_hashmap, dedup_vertices_exact,
dedup_vertices_epsilon, and filter_vertices_excluding functions to accept slices instead of vectors, improving performance by avoiding unnecessary cloning.

This aligns with the Rust agent's preference for borrowed APIs, taking references as arguments and returning borrowed views when possible, and only taking ownership when required.

Refs: refactor/borrow-first-utils

Updates `into_hashmap`, `dedup_vertices_exact`,
`dedup_vertices_epsilon`, and `filter_vertices_excluding`
functions to accept slices instead of vectors, improving
performance by avoiding unnecessary cloning.

This aligns with the Rust agent's preference for borrowed
APIs, taking references as arguments and returning borrowed
views when possible, and only taking ownership when required.

Refs: refactor/borrow-first-utils
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

Walkthrough

Public APIs were changed to prefer borrowed inputs: methods accepting owned Vec<T> now take generic IntoIterator<Item = T> or slices (&[T]) and documentation guidance was added advising borrowed/reference-based APIs in Rust.

Changes

Cohort / File(s) Summary
Documentation Guidance
AGENTS.md
Added guidance to prefer borrowed APIs (references, slices) and return borrowed views; advise taking ownership only when necessary.
into_hashmap Genericization
src/core/cell.rs, src/core/vertex.rs
Changed into_hashmap signatures to accept IntoIterator<Item = Self> (generic iterator) instead of Vec<Self>; examples and tests updated to pass arrays/iterators.
Slice-based Deduplication APIs
src/core/util/deduplication.rs
Changed dedup_vertices_exact, dedup_vertices_epsilon, and filter_vertices_excluding to accept &[Vertex<...>] instead of Vec<...>; internal loops and call sites/tests updated for borrowed iteration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

documentation

Poem

🐰
I hopped through code at dawn,
swapped Vec for gentle brawn —
references hum, slices sing,
iterators take wing.
Tiny paws, big change, hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: refactoring utility functions to use borrowed APIs (slices and references) instead of owned vectors.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the motivation (avoiding unnecessary cloning) and the specific functions being updated.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/borrow-first-utils

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

@coderabbitai coderabbitai bot added the rust Pull requests that update rust code label Feb 7, 2026
@codacy-production
Copy link

codacy-production bot commented Feb 7, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.01% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (abdeeb2) 10038 6330 63.06%
Head commit (9647518) 10038 (+0) 6329 (-1) 63.05% (-0.01%)

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 (#190) 5 5 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%

See your quality gate settings    Change summary preferences

@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.08%. Comparing base (abdeeb2) to head (9647518).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #190      +/-   ##
==========================================
- Coverage   63.09%   63.08%   -0.01%     
==========================================
  Files          46       46              
  Lines       10031    10031              
==========================================
- Hits         6329     6328       -1     
- Misses       3702     3703       +1     
Flag Coverage Δ
unittests 63.08% <100.00%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

Refactors `into_hashmap` functions for `Cell` and `Vertex` to accept
iterators instead of vectors. This improves flexibility by allowing
any iterable collection to be converted into a hashmap, and reduces
unnecessary allocations by avoiding intermediate vector copies.
@coderabbitai coderabbitai bot added the documentation Improvements or additions to documentation label Feb 7, 2026
@acgetchell acgetchell merged commit bee065b into main Feb 7, 2026
11 of 12 checks passed
@acgetchell acgetchell deleted the refactor/borrow-first-utils branch February 7, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant