std_macro_extensions/cout/macro.rs
1/// Print formatted output to standard output using `print!`.
2///
3/// # Parameters
4/// - `args`: A format string followed by optional expressions, just like in `print!`.
5///
6/// # Returns
7/// - Nothing. This macro prints directly to standard output.
8#[macro_export]
9macro_rules! cout {
10 ($($args: tt)*) => {
11 ::std::print!($($args)*);
12 let _ = ::std::io::Write::flush(&mut ::std::io::stdout());
13 };
14}
15
16/// Print a newline character and flush the standard output buffer.
17///
18/// # Parameters
19/// - (none): This macro takes no arguments.
20///
21/// # Returns
22/// - Nothing. This macro prints `\n` and flushes the output.
23#[macro_export]
24macro_rules! endl {
25 () => {{
26 $crate::cout!("\n");
27 }};
28}
29
30/// Print formatted output with a newline and flush the standard output buffer.
31///
32/// # Parameters
33/// - `args`: A format string followed by optional expressions, just like in `println!`.
34///
35/// # Returns
36/// - Nothing. This macro prints to standard output and flushes the buffer.
37#[macro_export]
38macro_rules! cout_endl {
39 ($($args:tt)*) => {
40 $crate::cout!($($args)*);
41 $crate::endl!();
42 };
43}