mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-19 22:19:29 +02:00
Fix example from zerocopy. (#2511)
This was changed incorrectly in #2434. Fixes #2472.
This commit is contained in:
parent
699cceadef
commit
fbeef48c50
@ -19,7 +19,8 @@ use std::{mem, slice};
|
||||
pub unsafe trait IntoBytes {
|
||||
fn as_bytes(&self) -> &[u8] {
|
||||
let len = mem::size_of_val(self);
|
||||
unsafe { slice::from_raw_parts((&raw const self).cast::<u8>(), len) }
|
||||
let slf: *const Self = self;
|
||||
unsafe { slice::from_raw_parts(slf.cast::<u8>(), len) }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user