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
166
167
168
169
use crate::;
/// A trait for writing or formatting into attributed Unicode-accepting buffers
/// or streams.
///
///
///
/// This trait only accepts UTF-8–encoded data and is not
/// [flushable](stylish::io::Write::flush). If you only want to accept Unicode
/// and you don’t need flushing, you should implement this trait; otherwise you
/// should implement [`stylish::io::Write`].
/// Writes attributed and formatted data into a buffer.
///
/// This macro accepts a 'writer', a format string, and a list of arguments.
/// Arguments will be formatted according to the specified format string and the
/// result will be passed to the writer. The writer may be any value with a
/// `write_fmt` method of the right signature; generally this comes from an
/// implementation of either the [`stylish::Write`] or the
/// [`stylish::io::Write`] trait. The macro returns whatever the `write_fmt`
/// method returns; commonly a [`core::fmt::Result`], or a [`std::io::Result`].
///
/// See [`stylish`] for more information on the format string syntax.
///
/// # Examples
///
/// ```rust
/// let mut w = stylish::html(String::new());
///
/// stylish::write!(&mut w, "test")?;
/// stylish::write!(&mut w, "formatted {:(fg=yellow)}", "arguments")?;
///
/// assert_eq!(
/// w.finish()?,
/// "testformatted <span style=color:yellow>arguments</span>"
/// );
/// # Ok::<(), core::fmt::Error>(())
/// ```
/// Write attributed and formatted data into a buffer, with a newline appended.
///
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`)
/// alone (no additional CARRIAGE RETURN (`\r`/`U+000D`).
///
/// For more information, see [`stylish::write!`]. For information on the format
/// string syntax, see [`stylish`].
///
/// # Examples
///
/// ```rust
/// let mut w = stylish::html(String::new());
///
/// stylish::writeln!(&mut w)?;
/// stylish::writeln!(&mut w, "test")?;
/// stylish::writeln!(&mut w, "formatted {:(fg=yellow)}", "arguments")?;
///
/// assert_eq!(w.finish()?, "\ntest\nformatted <span style=color:yellow>arguments</span>\n");
/// # Ok::<(), core::fmt::Error>(())