Skip to content

Instantly share code, notes, and snippets.

@dgellow
Last active January 10, 2022 11:03
Show Gist options
  • Save dgellow/87b68992fdf1509b3f758fbd264cf3fe to your computer and use it in GitHub Desktop.
Save dgellow/87b68992fdf1509b3f758fbd264cf3fe to your computer and use it in GitHub Desktop.
A simple Rust macro display!() that combines println!() and std::io::stdout::flush()
#[macro_export]
macro_rules! display {
( $($t:tt)* ) => {
{
use std::io::Write;
let mut out = std::io::stdout();
write!(out, $($t)* ).unwrap();
write!(out, "\n").unwrap();
out.flush().unwrap();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment