The `print_err!` macro in the Rust template is unnecessary

Fairly new to the forum and a quick search didn’t reveal this topic anywhere else.

Simply put, the recommended method of printing errors in Rust - the custom print_err macro - seems to be totally unnecessary. Rust already defines eprintln! which formats and prints to stderr with no apparent difference from how print_err does. Having print_err just makes the template cluttered, and if you never print to the standard error stream, raises a warning in the output if you don’t manually tag it with #[allow(unused_macros)].

The template may have been created when eprintln! wasn’t present, but right now I can use eprintln! in place of print_err! with no apparent ill effect. If there’s a good reason for the custom macro I’m open to hear it, but as it stands I can’t see any good reason it shouldn’t be replaced the next time the templates are revised.

5 Likes

Nice catch!
To be fair, this was added in rust 1.19, while the print_err! macro was quite useful when the rust version in codingame was older than that.

I figured as much - I wasn’t sure exactly when Rust was added to codingame nor when eprintln! was added, but I figured that they wouldn’t have made print_err! for nothing.

Solved! Thank you for alerting us on this.

1 Like