strings: remove wide pointer cast in CappedString impl
`CappedString::as_bytes` previously used a wide pointer cast to obtain a `&[u8]` from the `[MaybeUninit<u8>; N]` buffer; it cast a `*const [MaybeUninit<u8>]` to a `*const [u8]` as an intermediate step. Although this seems to be valid and did not cause any UB detected by MIRI, it seems to be generally accepted that `slice::from_raw_parts` is the preferred way to transmute slices since it makes explicit the metadata (length in this case) of the new wide pointer. This is in contrast to casting with `as`, which implicitly copies the metadata from the old wide pointer into the new one. Therefore, this patch replaces the `as *const [u8]` conversion with a call to `slice::from_raw_parts`.main
parent
7253d95010
commit
8309e19a68
Loading…
Reference in New Issue