Make must_cast by-value and by-shared-ref functions const #261
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.
(but not by-mut-ref, since that's not stable).
This would raise the MSRV of the
must_cast
feature from 1.57.0 to 1.64.0 (whenslice_from_raw_parts
was made const-stable). Alternately, this could be added as a new feature (const_must_cast
?) with its own MSRV1.The new arm of the
transmute!
macro is to work around borrowing a generic type in const-eval not being allowed on stable, since the borrowed type could have interior mutabilty. Transmuting viaunion
does not have this issue, since no borrowing occurs.Footnotes
must_cast
andmust_cast_ref
's MSRV is at least 1.61.0, whenconst_fn_trait_bound
was stabilized.must_cast_slice
's MSRV is at least 1.64.0, as mentioned. ↩