Nightly constify to_str (and everything on its path) #24
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_str
in 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_bytes
needs 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").