mirror of https://github.com/aya-rs/aya
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
7 lines
229 B
Rust
7 lines
229 B
Rust
2 years ago
|
use core::{mem, slice};
|
||
|
|
||
|
/// bytes_of converts a <T> to a byte slice
|
||
|
pub(crate) unsafe fn bytes_of<T>(val: &T) -> &[u8] {
|
||
|
let size = mem::size_of::<T>();
|
||
|
slice::from_raw_parts(slice::from_ref(val).as_ptr().cast(), size)
|
||
|
}
|