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
//! String creation utilities.
//!
//! The `s!` macro provides a convenient way to create `String` instances
//! with minimal boilerplate, supporting empty strings, direct conversion,
//! and format string syntax.
/// A convenience macro for creating `String` instances with various input types.
///
/// This macro provides three different ways to create a `String`:
/// - Create an empty string
/// - Convert any type implementing `ToString` to a `String`
/// - Use format string syntax with arguments
///
/// # Examples
///
/// ## Creating an empty string
/// ```
/// # use smacro::s;
/// let empty = s!();
/// assert_eq!(empty, String::new());
/// ```
///
/// ## Converting a value to string
/// ```
/// # use smacro::s;
/// let hello = s!("Hello, world!");
/// let number = s!(42);
/// let boolean = s!(true);
///
/// assert_eq!(hello, "Hello, world!".to_string());
/// assert_eq!(number, "42".to_string());
/// assert_eq!(boolean, "true".to_string());
/// ```
///
/// ## Format string with arguments
/// ```
/// # use smacro::s;
/// let name = "Alice";
/// let age = 30;
/// let greeting = s!("Hello, {}! You are {} years old.", name, age);
///
/// assert_eq!(greeting, "Hello, Alice! You are 30 years old.".to_string());
/// ```
///
/// ## More complex formatting
/// ```
/// # use smacro::s;
/// let x = 3.14159;
/// let formatted = s!("Pi is approximately {:.2}", x);
///
/// assert_eq!(formatted, "Pi is approximately 3.14".to_string());
/// ```
///
/// # Performance Note
///
/// This macro is a thin wrapper around standard Rust string creation methods:
/// - `s!()` calls `String::new()`
/// - `s!(expr)` calls `expr.to_string()`
/// - `s!(format_str, args...)` calls `format!(format_str, args...)`
///
/// There is no additional overhead compared to calling these methods directly.