Created
August 18, 2023 06:05
-
-
Save sam0x17/cc49788c50b9b88f11e7180616ab36ad to your computer and use it in GitHub Desktop.
evil rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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