logo
 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
#[macro_export]
macro_rules! css_attributes {
    ($($k:expr => $v:expr),* $(,)?) => {{
        std::iter::Iterator::collect(std::iter::IntoIterator::into_iter([$(CssAttribute::new($k.to_string(), $v.to_string()),)*]))
    }};
}

#[macro_export]
macro_rules! attributes_ensure {
    ($f:tt, $field:tt, $t:ty) => {
        #[inline]
        fn $f(&mut self) -> &mut $t {
            if self.$field.is_none() {
                self.$field = Some(Default::default())
            }
            unsafe { self.$field.as_mut().unwrap_unchecked() }
        }
    };
}

#[macro_export]
macro_rules! syntax_error {
    ($msg:literal $(,)?) => {
        Err(tailwind_error::TailwindError::syntax_error($msg.to_string()))
    };
    // ($err:expr $(,)?) => {
    //     Err(TailwindError::from($err))
    // };
    ($fmt:expr, $($arg:tt)*) => {
        Err(tailwind_error::TailwindError::syntax_error(format!($fmt, $($arg)*)))
    };
}