diff options
author | Nick Shipp <nick@shipp.ninja> | 2018-09-30 17:05:47 -0400 |
---|---|---|
committer | Nick Shipp <nick@shipp.ninja> | 2018-09-30 17:05:47 -0400 |
commit | df083e306a53e6a45a5730e7059032be43cc75ff (patch) | |
tree | d6e54f9fa587e7e001e2e751efad8e76e106b31f /bunny/src/inttraits.rs | |
parent | e8c36b131ac12832bb1d5de0e3a710733fca88ac (diff) |
Dirty rotten commit full of badness
Milestone: Got SMP cores booting and into long mode.
The rest is all trash, but maybe trash worth a future archaeological
dig.
Diffstat (limited to 'bunny/src/inttraits.rs')
-rw-r--r-- | bunny/src/inttraits.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bunny/src/inttraits.rs b/bunny/src/inttraits.rs new file mode 100644 index 0000000..5d402b3 --- /dev/null +++ b/bunny/src/inttraits.rs @@ -0,0 +1,14 @@ +use core::slice; +use core::mem::size_of; + +pub trait AsBytes: Sized { + fn as_bytes(&self) -> &[u8] { + unsafe { slice::from_raw_parts(self as *const _ as *const u8, size_of::<Self>()) } + } +} + +impl AsBytes for u128 {} +impl AsBytes for u64 {} +impl AsBytes for u32 {} +impl AsBytes for u16 {} +impl AsBytes for u8 {} |