Convert any type to a u8 slice (Like a C byte buffer)
(p: &T)
| 170 | |
| 171 | /// Convert any type to a u8 slice (Like a C byte buffer) |
| 172 | pub unsafe fn any_as_u8_slice<T: Sized>(p: &T) -> &[u8] { |
| 173 | let len = ::std::mem::size_of::<T>(); |
| 174 | ::std::slice::from_raw_parts((p as *const T) as *const u8, len) |
| 175 | } |
| 176 | |
| 177 | /// Convert any type to a mut u8 slice (Like a C byte buffer) |
| 178 | #[cfg(feature = "rusb")] |
no outgoing calls
no test coverage detected