skia_safe/
macros.rs

1#![macro_use]
2
3/// Macro to mark a Rust type as NativeTransmutable and test its layout.
4#[macro_export]
5macro_rules! native_transmutable {
6    ($nt:ty, $rt:ty, $test_fn:ident) => {
7        impl $crate::prelude::NativeTransmutable<$nt> for $rt {}
8        #[test]
9        fn $test_fn() {
10            use $crate::prelude::NativeTransmutable;
11            <$rt>::test_layout();
12        }
13    };
14}
15
16#[macro_export]
17macro_rules! require_type_equality {
18    ($t: ty, $nt: ty) => {
19        const _: fn(&$t) = |a| {
20            let _: &$nt = a;
21        };
22    };
23}
24
25#[macro_export]
26macro_rules! require_base_type {
27    ($t: ty, $nt: ty) => {
28        const _: fn(&$t) = |a| {
29            let _: &$nt = &(a._base);
30        };
31    };
32}
33
34/// Macro that implements Send and Sync.
35#[macro_export]
36macro_rules! unsafe_send_sync {
37    ($t: ty) => {
38        unsafe impl Send for $t {}
39        unsafe impl Sync for $t {}
40    };
41}
42
43/// Macro that verifies a variant name at compile time.
44#[macro_export]
45macro_rules! variant_name {
46    ($t:expr) => {
47        const _: fn() = || {
48            let _ = $t;
49        };
50    };
51}