-
Book Overview & Buying
-
Table Of Contents
Rust High Performance
By :
One of the most useful Rust functionalities is its macro ecosystem. You probably already know the println!() macro, but there are many more. These macros allow you to write complex boilerplate code (such as stdio handling in the println!() case) in a simple way and without having to add a ton of boilerplate code. Let's check out some of the most used ones.
When you need to lock the standard I/O interface, then write bytes to it, and finally flush it for each call, the print!() and println!() macros allow you to do that by just giving them a formatting static string and a series of parameters. Not only that, you can use the whole std::fmt module to specify number precision, format things in debug mode, and so on.
Similar macros exist for the standard error output interface or stderr. They are called eprint!() and eprintln!(), and allow you to easily print in stderr with the same format as print!() and println!(). The four macros use the syntax from the format!() macro...