Automattic / Automattic/harper

Leaky abstraction of `CharString` in two places.

Open Beginner friendly
#2,956 4 comments 0 reactions 0 assignees View on GitHub
harper-core help wanted question
Dominant language
Rust
Stars
15.4k
Forks
627
Avg merge
1d 15h
Merged PRs (30d)
106

Description

Our `CharString` type is actually a type alias for `SmallVec`.

This is respected everywhere in the codebase except two places:

- `harper_core::linting::spell_check::SpellCheck::uncached_suggest_correct_spelling()` uses `.to_smallvec()` to convert a `&&[char]` into a `CharString`
- `harper_core::spell::rune::attribute_list::AttributeList::apply_replacement()` also creates `replaced_segment` and `remove` using `.to_smallvec()`

This seems like a code smell to me. I'm not much more than a year into learning Rust though, so maybe this is normal?

I found it because I'm experimenting with upgrading `CharString` form a type alias to a newtype to make the code more expressive by enabling us to use `==` in many places we currently use very long-winded `.eq_ignore_ascii_case_chars()` and `.eq_ignore_ascii_case_str()`

Contributor guide

Open the contributing guide

Research direction

Start with SpellCheck::uncached_suggest_correct_spelling() and AttributeList::apply_replacement(), focusing on the two .to_smallvec() conversions described in the issue. Check how CharString is defined and used nearby, then confirm both paths preserve their existing behavior without exposing SmallVec; run the relevant Rust test suite to verify the refactor.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.