Skip to content

Instantly share code, notes, and snippets.

@sam0x17
Created August 18, 2023 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam0x17/cc49788c50b9b88f11e7180616ab36ad to your computer and use it in GitHub Desktop.
Save sam0x17/cc49788c50b9b88f11e7180616ab36ad to your computer and use it in GitHub Desktop.
evil rust
trait RawBytes: Sized {
fn raw_bytes(&self) -> &[u8] {
let ptr = self as *const Self as *const u8;
unsafe { core::slice::from_raw_parts(ptr, std::mem::size_of::<Self>()) }
}
}
impl<T> RawBytes for T {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment