-
-
Notifications
You must be signed in to change notification settings - Fork 202
Support Input types on ByteStr #944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for the nightly-only ByteStr type from std::bstr as an input type for chumsky parsers. The implementation follows the same pattern as the existing Bytes implementation, treating ByteStr as a byte-oriented string type with u8 tokens.
- Adds the
bstrfeature flag to the nightly feature set - Implements all necessary Input traits for
&ByteStr(Input, ExactSizeInput, StrInput, SliceInput, ValueInput)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/lib.rs | Adds bstr feature to nightly features and includes new bstr module |
| src/bstr.rs | Implements Input trait and related traits for ByteStr, following the pattern from Bytes implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| use super::*; | ||
| use core::bstr::ByteStr; |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding module-level documentation to explain the purpose of this module and when users should use ByteStr as an input type. Additionally, the Input trait documentation in src/input.rs (around lines 25-29) should be updated to include ByteStr in the list of common input types and their implemented traits, similar to how &str and &[T] are documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, listing it is superfluous and the impl will appear in the docs anyway
|
Thanks for the PR! I think the current implementation is correct, but I think it should instead call out to the existing slice impl. For example: #[inline(always)]
unsafe fn next_maybe(
this: &mut Self::Cache,
cursor: &mut Self::Cursor,
) -> Option<Self::MaybeToken> {
<&[u8]>::next_maybe(this, cursor)
}This makes the intent clearer and helps prevent any future divergence of the implementations. |
|
I tried this but some methods became too hard to parse. For example, |
This PR implements the usual
Inputtypes on the nightly only ByteStr type. The implementation is close to theBytestype but parts borrowed from the str implementation.