mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Add an important assert
This commit is contained in:
parent
a5dfa45797
commit
d415f1c31b
1 changed files with 1 additions and 0 deletions
|
@ -71,5 +71,6 @@ pub fn as_byte_array<T: Copy, const S: usize>(o: &T) -> &[u8; S] {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn to_byte_array<T: Copy, const S: usize>(o: T) -> [u8; S] {
|
pub fn to_byte_array<T: Copy, const S: usize>(o: T) -> [u8; S] {
|
||||||
assert_eq!(S, size_of::<T>());
|
assert_eq!(S, size_of::<T>());
|
||||||
|
assert!(!std::mem::needs_drop::<T>());
|
||||||
unsafe { *(&o as *const T).cast() }
|
unsafe { *(&o as *const T).cast() }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue