mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-27 18:43:12 -04:00
The previous implementation used an `unsafe` block to manually cast Vec's slice to a &[u8] using `core::slice::from_raw_parts`. Instead, the implementation can be implemented in safe rust using zerocopy's trait functions `as_bytes()` and `as_mut_bytes()`, respectively, and making use of deref coercion to implicitly cast Vec to &[T] as `FromBytes` and `IntoBytes` automatically are implemented on [T] when they are implemented on T. Signed-off-by: Josef Ippisch <josef.ippisch.dev@mailbox.org> Link: https://patch.msgid.link/20260728-migrate-binarywriter-to-zerocopy-intobytes-v2-2-0a4ec1d3ead4@mailbox.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>