tailwind_css_fixes/macros/exported/
mod.rs

1/// Define a css declaration block with a map-like syntax
2/// - CSS declaration block: collection of CSS property-value pairings
3/// - https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/CSS_Declaration_Block#basic_example
4#[macro_export]
5macro_rules! css_attributes {
6    () => {
7        CssAttributes::default()
8    };
9    ($($k:expr => $v:expr),* $(,)?) => {{
10        let mut css = CssAttributes::default();
11        $(crate::macros::sealed::css_insert!(css, $k, $v);)*
12        css
13    }};
14}
15
16///
17#[macro_export]
18macro_rules! attributes_ensure {
19    ($f:tt, $field:tt, $t:ty) => {
20        #[inline]
21        fn $f(&mut self) -> &mut $t {
22            if self.$field.is_none() {
23                self.$field = Some(Default::default())
24            }
25            unsafe { self.$field.as_mut().unwrap_unchecked() }
26        }
27    };
28}
29
30///
31#[macro_export]
32macro_rules! syntax_error {
33    ($msg:literal $(,)?) => {
34        Err(tailwind_error::TailwindError::syntax_error($msg.to_string()))
35    };
36    // ($err:expr $(,)?) => {
37    //     Err(TailwindError::from($err))
38    // };
39    ($fmt:expr, $($arg:tt)*) => {
40        Err(tailwind_error::TailwindError::syntax_error(format!($fmt, $($arg)*)))
41    };
42}