Drop unnecessary mutable reference to self in Seq::mutate

Open Beginner friendly
#26 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Quiet
Tech stack
rust

Research direction

Start with the definitions of Seq::mutate and mutate_in_place, then inspect their callers to understand the required receiver change. Done means mutate no longer requires a mutable reference while preserving copy-on-modify behavior and the existing Result semantics.

Written by the indexing model from the issue text.

Description

Problem

Our biological sequence mutate api takes a mutable reference to self:

 pub fn mutate(&mut self, interval: Interval, new: Option<&Seq<B>>) -> Result<Self> { ... }

However, inkeeping with the design philosophy of this crate (All sequence operations should be copy-on-modify unless you opt in to an in-place variant mutate_in_place) the mutate method does NOT modify the original data. Instead it clones the sequence and then calls mutate_in_place on the copy.

This was probably so I could write one implementation that actually performs the mutation (in place) and reuse everywhere so it can stay in sync. But the downside is we take a mutable reference to self despite never changing the original data - making the function signature very deceptive.

Dominant language
Rust
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from selkamand/seqlib

All issues in selkamand/seqlib

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.