Skip to content

Fix Clippy loop-counter lint in solvate residue assignment - #2

Merged
colbyford merged 2 commits into
mainfrom
copilot/fix-loop-counter-error
May 23, 2026
Merged

colbyford merged 2 commits into
mainfrom
copilot/fix-loop-counter-error

Conversation

Copilot AI commented May 23, 2026

Copy link
Copy Markdown

Clippy fails in crates/bio-forge/src/ops/solvate.rs because res_id_counter was used as a manual loop counter when assigning IDs to generated water residues. This updates the loop to use idiomatic iterator zipping while preserving residue ID sequencing and insertion order.

  • Root cause

    • Water residue IDs were assigned via a mutable external counter incremented inside for mut residue in new_waters.
  • Code change

    • Replaced manual counter state with (1..).zip(new_waters) and destructured (res_id_counter, mut residue) in the loop.
    • Kept existing behavior for:
      • residue.id assignment
      • solvent_chain.add_residue(residue)
      • water_positions.push(res_id_counter)
  • Representative diff

    for (res_id_counter, mut residue) in (1..).zip(new_waters) {
        residue.id = res_id_counter;
        solvent_chain.add_residue(residue);
        water_positions.push(res_id_counter);
    }

@colbyford
colbyford marked this pull request as ready for review May 23, 2026 01:28
@colbyford
colbyford merged commit dc7e4d3 into main May 23, 2026
8 checks passed
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