feat: add rayon feature - #487
Open
ParkMyCar wants to merge 2 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #432.
Adds an optional
rayonfeature soCompactStringworks with rayon's parallel iterators the same wayStringdoes. It implements bothFromParallelIteratorandParallelExtendfor every item type rayon supports forString—char,&char,&str,String,Box<str>,Cow<str>— plus theItem = CompactStringvariants the issue asked for, including collecting/extending aStringfromCompactStrings (allowed by the orphan rule sinceCompactStringis local).Each impl delegates the actual parallel collection to
String(reusing rayon's optimized string collectors) and then converts, so the behavior matchesStringexactly — the two proptests assert that directly (collect/par_extendintoCompactStringvsStringproduce identical results). The feature pulls instd(rayon needs it), and there's nounsafein the module.Tests are
#[cfg_attr(miri, ignore)]— rayon's thread pool is far too slow under Miri, and there's nounsafehere for it to check anyway.Verified:
--features rayonbuilds, the 7 tests pass (5 unit + 2String-parity proptests at 5k cases),--all-featuressuite green (331 + 84), clippy clean under-D warnings, fmt clean, and--no-default-features --features rayoncompiles (the feature enablesstd). Added README and CHANGELOG entries.