Skip to content

refactor: Getting rid of clippy slicing#2735

Open
SimonRastikian wants to merge 5 commits intomainfrom
simon/getting-rid-of-indexing-slicing
Open

refactor: Getting rid of clippy slicing#2735
SimonRastikian wants to merge 5 commits intomainfrom
simon/getting-rid-of-indexing-slicing

Conversation

@SimonRastikian
Copy link
Copy Markdown
Contributor

Reworks near/threshold-signatures#122
Remove the blanket #![allow(clippy::indexing_slicing)]
In some spots I added input validation and converted iterators to prevent using indexing

@claude
Copy link
Copy Markdown

claude bot commented Apr 7, 2026

PR title format: This PR is missing a conventional commit type prefix. Since it fixes clippy linting warnings without changing functionality, the type should be style:

Suggested title: style: fix clippy slicing warnings

@claude
Copy link
Copy Markdown

claude bot commented Apr 7, 2026

Code Review

No critical issues found. The PR cleanly replaces blanket #![allow(clippy::indexing_slicing)] with:

  • Scoped #[allow(...)] with safety invariant comments (strobe.rs)
  • Iterator/zip-based loops instead of index-based loops
  • Input validation (len < N checks, .first(), .get()) before access

The zip-based rewrites correctly preserve original loop semantics — zip stops at the shorter iterator, which matches the original 0..N bounds after the added length guards.

✅ Approved

@claude
Copy link
Copy Markdown

claude bot commented Apr 7, 2026

PR title type suggestion: This PR should use a conventional commit type prefix. Since it's restructuring code to address clippy warnings, the type should be refactor:.
Suggested title: refactor: address clippy slicing warnings

@SimonRastikian SimonRastikian changed the title Getting rid of clippy slicing refactor: Getting rid of clippy slicing Apr 7, 2026
@SimonRastikian SimonRastikian marked this pull request as draft April 7, 2026 10:51
@SimonRastikian SimonRastikian marked this pull request as ready for review April 7, 2026 12:56
@claude
Copy link
Copy Markdown

claude bot commented Apr 7, 2026

Code Review

No critical issues found. The changes correctly:

  • Replace blanket #![allow(clippy::indexing_slicing)] with scoped #[allow(...)] annotations with safety invariant comments (strobe.rs)
  • Convert index-based loops to iterator/zip-based loops throughout
  • Add input length validation (len < N checks, .first(), .get(), split_first()) before access
  • Return ProtocolError::AssertionFailed on validation failures rather than panicking

The zip-based rewrites correctly preserve original loop semantics — zip stops at the shorter iterator, which matches the original 0..N bounds, and the added length guards ensure the receiving vectors are at least N long.

✅ Approved


Reviewed with Claude Code

Copy link
Copy Markdown
Collaborator

@netrome netrome left a comment

Choose a reason for hiding this comment

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

Nice stuff, thanks for fixing. Would be nice to use multizip to make the zip chain a bit prettier but not a hard blocker.

Comment on lines +356 to +367
.zip(their.big_e_v.iter())
.zip(their.big_f_v.iter())
.zip(their.big_l_v.iter())
.zip(their.randomizer_v.iter())
.zip(their.phi_proof0_v.iter())
.zip(their.phi_proof1_v.iter())
.zip(
big_e_j_zero_v.iter_mut().zip(
big_e_v
.iter_mut()
.zip(big_f_v.iter_mut())
.zip(big_l_v.iter_mut()),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure I've ever seen this many zips in the same expression 😂

Perhaps worth including itertools (we already have it in the workspace) and use multizip https://docs.rs/itertools/latest/itertools/fn.multizip.html

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.

2 participants