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) => {
7        impl $crate::prelude::NativeTransmutable<$nt> for $rt {}
8        const _: () = {
9            $crate::prelude::assert_layout_compatible::<$nt, $rt>();
10        };
11    };
12}
13
14#[macro_export]
15macro_rules! require_type_equality {
16    ($t: ty, $nt: ty) => {
17        const _: fn(&$t) = |a| {
18            let _: &$nt = a;
19        };
20    };
21}
22
23#[macro_export]
24macro_rules! require_base_type {
25    ($t: ty, $nt: ty) => {
26        const _: fn(&$t) = |a| {
27            let _: &$nt = &(a._base);
28        };
29    };
30}
31
32/// Macro that implements Send and Sync.
33#[macro_export]
34macro_rules! unsafe_send_sync {
35    ($t: ty) => {
36        unsafe impl Send for $t {}
37        unsafe impl Sync for $t {}
38    };
39}
40
41/// Macro that verifies a variant name at compile time.
42#[macro_export]
43macro_rules! variant_name {
44    ($t:expr) => {
45        const _: () = {
46            let _ = $t;
47        };
48    };
49}