Skip to content

feat: add rayon feature - #487

Open
ParkMyCar wants to merge 2 commits into
mainfrom
feat/rayon
Open

feat: add rayon feature#487
ParkMyCar wants to merge 2 commits into
mainfrom
feat/rayon

Conversation

@ParkMyCar

@ParkMyCar ParkMyCar commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Closes #432.

Adds an optional rayon feature so CompactString works with rayon's parallel iterators the same way String does. It implements both FromParallelIterator and ParallelExtend for every item type rayon supports for Stringchar, &char, &str, String, Box<str>, Cow<str> — plus the Item = CompactString variants the issue asked for, including collecting/extending a String from CompactStrings (allowed by the orphan rule since CompactString is local).

Each impl delegates the actual parallel collection to String (reusing rayon's optimized string collectors) and then converts, so the behavior matches String exactly — the two proptests assert that directly (collect/par_extend into CompactString vs String produce identical results). The feature pulls in std (rayon needs it), and there's no unsafe in the module.

Tests are #[cfg_attr(miri, ignore)] — rayon's thread pool is far too slow under Miri, and there's no unsafe here for it to check anyway.

Verified: --features rayon builds, the 7 tests pass (5 unit + 2 String-parity proptests at 5k cases), --all-features suite green (331 + 84), clippy clean under -D warnings, fmt clean, and --no-default-features --features rayon compiles (the feature enables std). Added README and CHANGELOG entries.

ParkMyCar and others added 2 commits July 12, 2026 03:28
Adds an optional `rayon` feature implementing `FromParallelIterator` and
`ParallelExtend` for `CompactString`, mirroring the impls rayon provides for
`String` (char, &char, &str, String, Box<str>, Cow<str>) plus the
`Item = CompactString` variants -- including collecting/extending a `String`
from `CompactString`s. Each impl delegates the parallel collection to `String`
and converts, so behavior matches `String` exactly.

Closes #432

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGTA38KYXfd6EgVAiUYJ1e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VGTA38KYXfd6EgVAiUYJ1e
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.

rayon feature

1 participant