Nightly constify to_str (and everything on its path)#24
Merged
Amanieu merged 3 commits intoAmanieu:masterfrom Dec 21, 2021
Merged
Nightly constify to_str (and everything on its path)#24Amanieu merged 3 commits intoAmanieu:masterfrom
Amanieu merged 3 commits intoAmanieu:masterfrom
Conversation
As is currently being done in other functions, this duplicates the function and adds the `const` keyword.
This requires a slightly different implementation that goes through unsafe from_parts, as slicing is not available in a const fashion yet.
As is currently being done in other functions, this duplicates the function and adds the `const` keyword.
Owner
|
LGTM! |
Owner
|
Do you want me to publish a new release now or do you have other changes planned? |
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.
This constifies
to_strin three progressive steps.Two new features are enabled at nightly const_str_from_utf8 and const_slice_from_raw_parts. The former is rather new (but appears to be unproblematic), the latter has been around for over a year (and doesn't look troublesome either).
Two functions (
to_str,to_bytes_with_nul) are constified without actual code changes;to_bytesneeds code changes for nightly (it builds the slice through unsafe from_parts rather than slicing). If the former are too much duplication, it'd be an option to pull in const_ft to let preprocessor do it, similar to how Rust itself usesrustc_const_unstable. (Might actually not be a dependency but copied in, because it's using a hardcoded feature name that is not "nighlty").