Skip to content

Let Extractor::new take a reference or an AnalysisType, and shorten compare_birthmarks - #215

Merged
tamada merged 5 commits into
mainfrom
feat/extractor-new-into
Oct 22, 2026
Merged

tamada merged 5 commits into
mainfrom
feat/extractor-new-into

Conversation

@tamada

@tamada tamada commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Extractor::new

Extractor::new takes impl Into<BirthmarkType>, and BirthmarkType converts from &BirthmarkType, AnalysisType and &AnalysisType.

  • A caller holding an analysis writes Extractor::new(&analysis) rather than Extractor::new(analysis.birthmark().clone()).
  • An owned BirthmarkType is still moved in without a copy, and code that passed one compiles unchanged.
  • The README, the crate docs, the CLI, the MCP server and the tests use the new forms.
  • .github/public-api.txt is updated for the new signature and the three From impls, and v0.9.0's release notes say what changed.

compare_birthmarks

compare_birthmarks is split so that it reads as the steps it takes:

  • empty_comparison makes the comparison of an empty birthmark.
  • Birthmark::function_mapper maps each birthmark's functions. Its lifetime lets the closure return what borrows from the functions, such as the Cow<Data> that in_shape returns.

cargo test --features mcp (410 tests, doctests included), clippy with -D warnings and the public API check pass locally.

🤖 Generated with Claude Code

tamada and others added 5 commits October 22, 2026 10:51
Extractor::new takes `impl Into<BirthmarkType>`, and BirthmarkType converts
from &BirthmarkType, AnalysisType and &AnalysisType. A caller holding an
analysis or a borrowed birthmark type passes it as it is, rather than
cloning the birthmark type out first; an owned BirthmarkType is still moved
in without a copy.
The comparison of an empty birthmark is made by empty_comparison, and each
birthmark's functions are mapped by Birthmark::function_mapper, so
compare_birthmarks reads as the steps it takes.
…lifetime

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compare_birthmarks took both lists of sizes from the first birthmark, so the
weighted aggregator refused any pair whose birthmarks held different numbers
of functions, and weighted by the wrong sizes when they held the same.
Two birthmarks of the same number of functions but different sizes, so that
taking both sides' sizes from one birthmark passes every length check and is
caught by the score alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@tamada tamada self-assigned this Oct 22, 2026
@tamada tamada added the enhancement New feature or request label Oct 22, 2026
@tamada tamada added this to the v0.9.0 milestone Oct 22, 2026
@tamada
tamada merged commit c798684 into main Oct 22, 2026
8 checks passed
@tamada
tamada deleted the feat/extractor-new-into branch October 22, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant