-
Notifications
You must be signed in to change notification settings - Fork 24
Use newer const fn features #89
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
Merged
Merged
Conversation
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
1.57 is quite recent. |
Merged
e8c19d4
to
d49cce5
Compare
Lowered MSRV to 1.57 by replacing casts through raw pointers with transmute. |
af35d53
to
93263ba
Compare
Enabled by Rust 1.46 as part of const if/else.
* AsciiChar::from_ascii_unchecked() * AsciiChar::as_printable_char()
As `const fn` alternatives to the trait-based from_ascii(). Closes tomprogrammer#84
* AsciiStr::as_str() * AsciiStr::as_bytes() Dereferencing raw pointers in `const fn` requires Rust 1.58, while transmute only requires Rust 1.56.
* AsciiStr::trim_start() * AsciiStr::trim_end() * AsciiStr::trim()
Would it be possible to cut a new release onto crates.io with this? It'd be really useful to be able to use some of these in a const context. |
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.
Existing methods made
const fn
:(done in Misc. improvements #95)AsciiStr::len()
(done in Misc. improvements #95)AsciiStr::is_empty()
AsciiStr::as_str()
AsciiStr::as_bytes()
AsciiStr::trim()
AsciiStr::trim_left()
AsciiStr::trim_right()
AsciiChar::from_ascii_unchecked()
AsciiChar::as_printable_char()
(postponed)AsciiChar::is_digit()
New methods:
AsciiStr::new([AsciiChar])
AsciiStr::from_ascii_bytes()
AsciiStr::from_ascii_str()
AsciiChar::try_new(char)
Also switch back to
&&
and||
in many methods,and(postponed).panic!()
inAsciiChar::new()
This increases MSRV
all the way to 1.571.56.