Allow casting between slices of ZSTs and slices of non-ZSTs in all cases. #256
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.
Closes #253.
This PR implements that. Additionally, casting non-ZST slices to ZST slices will work iff the input slice has length 0, and results in a slice length of 0; if the input slice is not of length 0,
PodCastError::OutputSliceWouldHaveSlop
is returned.Updates the docs of the
PodCastError
variants to reflect when they can occur.Updates the docs of
try_cast_slice
(andchecked::
) to remove note about ZST <-> non-ZST not being allowed.Update
bytes_of(_mut)
to remove ZST-may-not-have-same-address exception, since casting [ZST] -> [u8] is now allowed directly usingcast_slice(_mut)
(but does not remove the documentation of the exception just in case).Update
must_cast_slice
checks and doctests to allow [ZST] -> [non-ZST], but disallow [non-ZST] -> [ZST].