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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Add crate-level attributes
// Remove unsafe forbid since we use unsafe transmute
// #![forbid(unsafe_code)]
//! A Rust macro library for compile-time CSS class name concatenation and processing
//!
//! # Features
//!
//! - Zero runtime overhead - everything happens at compile time
//! - Automatic whitespace handling and normalization
//! - Support for concatenating multiple class names
//! - Removes leading/trailing whitespace and collapses multiple spaces
//!
//! # Examples
//!
//! Basic usage:
//! ```rust
//! use classnames_const_rs::*;
//!
//! const BUTTON_CLASS: &str = classnames_concat!("btn", "btn-primary");
//! assert_eq!(BUTTON_CLASS, "btn btn-primary");
//! ```
//!
//! Handling messy whitespace:
//! ```rust
//! use classnames_const_rs::*;
//!
//! const COMPLEX_CLASS: &str = classnames_concat!("header ", " main ", "footer");
//! assert_eq!(COMPLEX_CLASS, "header main footer");
//! ```
//!
//! Empty strings are handled gracefully:
//! ```rust
//! use classnames_const_rs::*;
//!
//! const SPARSE_CLASS: &str = classnames_concat!("", "active", "", "highlight");
//! assert_eq!(SPARSE_CLASS, "active highlight");
//! ```
/// Concatenates multiple class name strings with automatic whitespace handling
///
/// This macro performs compile-time concatenation of class names, ensuring that:
/// - Class names are separated by single spaces
/// - Leading and trailing whitespace is removed
/// - Multiple consecutive spaces are collapsed to single spaces
///
/// # Examples
///
/// ```rust
/// use classnames_const_rs::{classnames_concat, trim_format};;
///
/// const CLASSES: &str = classnames_concat!("btn", "btn-large", "btn-primary");
/// assert_eq!(CLASSES, "btn btn-large btn-primary");
///
/// const MESSY_CLASSES: &str = classnames_concat!(" header ", " main ", "footer ");
/// assert_eq!(MESSY_CLASSES, "header main footer");
/// ```
/// Formats a string by normalizing whitespace characters
///
/// This macro processes strings at compile time to:
/// - Replace consecutive whitespace characters with single spaces
/// - Remove leading and trailing whitespace
/// - Handle various whitespace characters (spaces, tabs, newlines, etc.)
///
/// This macro is primarily used internally by `classnames_concat` and typically
/// doesn't need to be called directly.
///
/// # Examples
///
/// ```rust
/// use classnames_const_rs::*;
///
/// const NORMALIZED: &str = trim_format!(" hello world ");
/// assert_eq!(NORMALIZED, "hello world");
/// ```