argmin/
macros.rs

1// Copyright 2018-2020 argmin developers
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7
8//! # Macros
9
10/// This macro crates a test for send an sync
11#[cfg(test)]
12#[macro_export]
13macro_rules! test_trait_impl {
14    ($n:ident, $t:ty) => {
15        paste::item! {
16            #[test]
17            #[allow(non_snake_case)]
18            fn [<test_send_ $n>]() {
19                fn assert_send<T: Send>() {}
20                assert_send::<$t>();
21            }
22        }
23
24        paste::item! {
25            #[test]
26            #[allow(non_snake_case)]
27            fn [<test_sync_ $n>]() {
28                fn assert_sync<T: Sync>() {}
29                assert_sync::<$t>();
30            }
31        }
32
33        paste::item! {
34            #[test]
35            #[allow(non_snake_case)]
36            fn [<test_clone_ $n>]() {
37                fn assert_clone<T: Clone>() {}
38                assert_clone::<$t>();
39            }
40        }
41    };
42}