Skip to content

Commit

Permalink
Fix example from zerocopy. (#2511)
Browse files Browse the repository at this point in the history
This was changed incorrectly in #2434.

Fixes #2472.
  • Loading branch information
qwandor authored Dec 13, 2024
1 parent 699ccea commit fbeef48
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/unsafe-rust/unsafe-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}
Expand Down

0 comments on commit fbeef48

Please sign in to comment.