about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2015-08-27 14:04:28 -0400
committerSteve Klabnik <steve@steveklabnik.com>2015-08-27 19:02:45 -0400
commitd9819b76d258a17a70b4e58331bd4e58cfcc5a55 (patch)
tree215a47a81c16cd6a9c59ee1d5ccc91d7ed550e6f /src
parentccf831769459fb1b306387e6796a0155d63eb012 (diff)
downloadrust-d9819b76d258a17a70b4e58331bd4e58cfcc5a55.tar.gz
rust-d9819b76d258a17a70b4e58331bd4e58cfcc5a55.zip
Add some examples for the print! macro
Diffstat (limited to 'src')
-rw-r--r--src/libstd/macros.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs
index 53a14c2b21b..f08ac0728ea 100644
--- a/src/libstd/macros.rs
+++ b/src/libstd/macros.rs
@@ -67,6 +67,26 @@ macro_rules! panic {
 /// Note that stdout is frequently line-buffered by default so it may be
 /// necessary to use `io::stdout().flush()` to ensure the output is emitted
 /// immediately.
+///
+/// # Examples
+///
+/// ```
+/// use std::io::{self, Write};
+///
+/// print!("this ");
+/// print!("will ");
+/// print!("be ");
+/// print!("on ");
+/// print!("the ");
+/// print!("same ");
+/// print!("line ");
+///
+/// io::stdout().flush().unwrap();
+///
+/// print!("this string has a newline, why not choose println! instead?\n");
+///
+/// io::stdout().flush().unwrap();
+/// ```
 #[macro_export]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[allow_internal_unstable]