Last active
June 29, 2016 20:05
-
-
Save jwilm/16ce667076b854fbae55568f340c6a84 to your computer and use it in GitHub Desktop.
Revisions
-
jwilm revised this gist
Jun 29, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ /// Improved println! macro that allows specifying stdout or stderr /// /// # Examples /// -
jwilm revised this gist
Jun 29, 2016 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,21 +12,21 @@ /// zprintln!(stderr, "Hello, stderr!"); /// ``` macro_rules! zprintln { (stdout, $($arg:tt)*) => { println!($($arg)*); }; (stderr, $($arg:tt)*) => {{ use std::io::Write; writeln!(::std::io::stderr(), $($arg)*).unwrap(); }}; ($($arg:tt)*) => { println!($($arg)*); }; } fn main() { zprintln!("normal shows up on stdout"); zprintln!("normal shows up on stdout with arg: {}", 1); zprintln!(stdout, "with stdout goes to stdout: {}", 1); zprintln!(stderr, "with stderr goes to stderr: {}", 2); } -
jwilm revised this gist
Jun 29, 2016 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,16 @@ /// Improved println! macro that allows specifying the stdout or stderr /// /// # Examples /// /// Printing to stdout works like normal /// ```rust /// zprintln!("Hello, zprintln!"); /// ``` /// /// Printing to stderr works by passing a special argument /// ```rust /// zprintln!(stderr, "Hello, stderr!"); /// ``` macro_rules! zprintln { ($($arg:tt)*) => { println!($($arg)*); -
jwilm created this gist
Jun 29, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ macro_rules! zprintln { ($($arg:tt)*) => { println!($($arg)*); } (stdout, $($arg:tt)*) => { println!($($arg)*); }; (stderr, $($arg:tt)*) => {{ use std::io::Write; writeln!(::std::io::stderr(), $($arg)*).unwrap(); }}; } fn main() { zprintln!("normal shows up on stdout"); zprintln!("normal shows up on stdout with arg: {}", 1); zprintln!(stdout, "with stdout goes to stdout: {}", 1); zprintln!(stderr, "with stderr goes to stderr: {}", 2); }