pantonshire 8309e19a68 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`.
2022-09-18 21:21:45 +01:00
2022-05-15 17:14:39 +01:00
2022-05-15 18:32:30 +01:00

libshire

A collection of assorted Rust utilities for reuse between various projects 🦀

S
Description
Assorted utilities
Readme
151 KiB
0 Stars 1 Watchers 0 Forks
Languages
Rust 99.7%
Shell 0.3%