macro
eprintln! — Write an error message on its own line
Send a diagnostic to stderr while leaving normal results on stdout. Both streams may appear together in a terminal, but a calling program can capture them separately. This does not set an error exit status. Expression result: (). Expected result (not executed): stdout: 'Using defaults\n'; stderr : 'Cannot open settings.toml\n' Common mistake: Assuming eprintln! terminates the program or changes its exit status.
Formal Syntax & Structure
rust syntaxrust
eprintln!("format string", arguments...)Working Example
Example Snippetrust
fn main() { let path = "settings.toml"; eprintln!("Cannot open {path}"); println!("Using defaults");}