irox_tools/
macros.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// SPDX-License-Identifier: MIT
// Copyright 2024 IROX Contributors
//

//!
//! Macros for better documentation.

/// Enables Windows-specific code.
/// Use this macro instead of `cfg(windows)` to generate docs properly.
#[macro_export]
macro_rules! cfg_windows {
    ($($item:item)*) => {
        $(
            #[cfg(any(all(doc, docsrs), windows))]
            #[cfg_attr(docsrs, doc(cfg(windows)))]
            $item
        )*
    }
}

/// Enables Unix-specific code.
/// Use this macro instead of `cfg(unix)` to generate docs properly.
#[macro_export]
macro_rules! cfg_unix {
    ($($item:item)*) => {
        $(
            #[cfg(any(all(doc, docsrs), unix))]
            #[cfg_attr(docsrs, doc(cfg(unix)))]
            $item
        )*
    }
}

/// Enables feature-specific code.
/// Use this macro instead of `cfg(feature = "std")` to generate docs properly.
#[macro_export]
macro_rules! cfg_feature_std {
    ($($item:item)*) => {
        $(
            #[cfg(any(all(doc, docsrs), feature = "std"))]
            #[cfg_attr(docsrs, doc(cfg(feature = "std")))]
            $item
        )*
    }
}

/// Enables feature-specific code.
/// Use this macro instead of `cfg(feature = "alloc")` to generate docs properly.
#[macro_export]
macro_rules! cfg_feature_alloc {
    ($($item:item)*) => {
        $(
            #[cfg(any(all(doc, docsrs), feature = "alloc"))]
            #[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
            $item
        )*
    }
}

/// Enables feature-specific code.
/// Use this macro instead of `cfg(feature = "serde")` to generate docs properly.
#[macro_export]
macro_rules! cfg_feature_serde {
    ($($item:item)*) => {
        $(
            #[cfg(any(all(doc, docsrs), feature = "serde"))]
            #[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
            $item
        )*
    }
}

/// Enables feature-specific code.
/// Use this macro instead of `cfg(feature = "bits")` to generate docs properly.
#[macro_export]
macro_rules! cfg_feature_bits {
    ($($item:item)*) => {
        $(
            #[cfg(any(all(doc, docsrs), feature = "bits"))]
            #[cfg_attr(docsrs, doc(cfg(feature = "bits")))]
            $item
        )*
    }
}

/// Enables feature-specific code.
/// Use this macro instead of `cfg(feature = "egui")` to generate docs properly.
#[macro_export]
macro_rules! cfg_feature_egui {
    ($($item:item)*) => {
        $(
            #[cfg(any(all(doc, docsrs), feature = "egui"))]
            #[cfg_attr(docsrs, doc(cfg(feature = "egui")))]
            $item
        )*
    }
}

/// Enables feature-specific code.
/// Use this macro instead of `cfg(feature = "plots")` to generate docs properly.
#[macro_export]
macro_rules! cfg_feature_plots {
    ($($item:item)*) => {
        $(
            #[cfg(any(all(doc, docsrs), feature = "plots"))]
            #[cfg_attr(docsrs, doc(cfg(feature = "plots")))]
            $item
        )*
    }
}

/// Enables feature-specific code.
/// Use this macro instead of `cfg(feature = "git")` to generate docs properly.
#[macro_export]
macro_rules! cfg_feature_git {
    ($($item:item)*) => {
        $(
            #[cfg(any(all(doc, docsrs), feature = "git"))]
            #[cfg_attr(docsrs, doc(cfg(feature = "git")))]
            $item
        )*
    }
}