pprint

Macro pprint 

Source
macro_rules! pprint {
    ($($t:tt)*) => { ... };
}
Expand description

Prints values with a specified format, returning a Result.

This macro is similar to Python’s print() function, allowing for customization of separators, line endings, and output destination.

§Options

  • sep=VALUE: Sets the separator between items (default: “ “)
  • end=VALUE: Sets the ending string (default: “\n”)
  • file=VALUE: Sets the output destination (default: stdout)
  • flush=BOOL: Controls whether to flush output immediately

§Examples

use pyprint::pprint;
 
// Basic printing
pprint!("Hello", "World");
 
// With custom separator and ending
pprint!("Hello", "World", sep=" - ", end="!\n");
 
// Print to a custom output
use std::fs::File;
let file = File::create("output.txt").unwrap();
pprint!(file=file, "Hello", "World");