@@ -168,8 +168,14 @@ macro_rules! try {
168
168
} )
169
169
}
170
170
171
- /// Use the `format!` syntax to write data into a buffer of type `&mut Write`.
172
- /// See `std::fmt` for more information.
171
+ /// Use the `format!` syntax to write data into a buffer.
172
+ ///
173
+ /// This macro is typically used with a buffer of `&mut `[`Write`][write].
174
+ ///
175
+ /// See [`std::fmt`][fmt] for more information on format syntax.
176
+ ///
177
+ /// [fmt]: fmt/index.html
178
+ /// [write]: io/trait.Write.html
173
179
///
174
180
/// # Examples
175
181
///
@@ -179,14 +185,34 @@ macro_rules! try {
179
185
/// let mut w = Vec::new();
180
186
/// write!(&mut w, "test").unwrap();
181
187
/// write!(&mut w, "formatted {}", "arguments").unwrap();
188
+ ///
189
+ /// assert_eq!(w, b"testformatted arguments");
182
190
/// ```
183
191
#[ macro_export]
184
192
macro_rules! write {
185
193
( $dst: expr, $( $arg: tt) * ) => ( $dst. write_fmt( format_args!( $( $arg) * ) ) )
186
194
}
187
195
188
- /// Equivalent to the `write!` macro, except that a newline is appended after
189
- /// the message is written.
196
+ /// Use the `format!` syntax to write data into a buffer, appending a newline.
197
+ ///
198
+ /// This macro is typically used with a buffer of `&mut `[`Write`][write].
199
+ ///
200
+ /// See [`std::fmt`][fmt] for more information on format syntax.
201
+ ///
202
+ /// [fmt]: fmt/index.html
203
+ /// [write]: io/trait.Write.html
204
+ ///
205
+ /// # Examples
206
+ ///
207
+ /// ```
208
+ /// use std::io::Write;
209
+ ///
210
+ /// let mut w = Vec::new();
211
+ /// writeln!(&mut w, "test").unwrap();
212
+ /// writeln!(&mut w, "formatted {}", "arguments").unwrap();
213
+ ///
214
+ /// assert_eq!(&w[..], "test\nformatted arguments\n".as_bytes());
215
+ /// ```
190
216
#[ macro_export]
191
217
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
192
218
macro_rules! writeln {
0 commit comments