ffizz-passby 0.5.0

FFI helpers for implementing pass-by-value and pass-by-pointer
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::mem;

/// Verify that CType and RType have the same alignment requirements, and that RType is not larger
/// than CType.
///
/// These checks will compile to nothing if the requirements are met, and will compile to
/// `debug_assert!(false)` if they are not met, causing all trait methods to panic.  That should be
/// enough to get someone's attention!
pub(crate) fn check_size_and_alignment<CType: Sized, RType: Sized>() {
    debug_assert!(mem::size_of::<RType>() <= mem::size_of::<CType>());
    debug_assert!(mem::align_of::<RType>() == mem::align_of::<CType>());
}