having ZST slices turn into 0-length non-ZST slices does seem like a compelling path.
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 (and checked::) 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 using cast_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].
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 oftry_cast_slice
(andchecked::
) to remove note about ZST <-> non-ZST not being allowed. Updatebytes_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). Updatemust_cast_slice
checks and doctests to allow [ZST] -> [non-ZST], but disallow [non-ZST] -> [ZST].