rustHow to print error in Rust
Rust provides a standard library macro called eprintln!
to print errors to the standard error output. This macro is similar to the println!
macro, but prints to the standard error instead of the standard output.
Code example:
fn main() {
eprintln!("This is an error message");
}
Output
This is an error message
Explanation:
eprintln!
: This is a macro provided by the Rust standard library to print errors to the standard error output.This is an error message
: This is the message that will be printed to the standard error output.
Helpful links:
More of Rust
- How to get a capture group using Rust regex?
- How to use regex with bytes in Rust?
- How to match the end of a line in a Rust regex?
- Hashshet example in Rust
- How to create a new Rust HashMap with values?
- How do I use a variable from another file in Rust?
- How to get the length of a Rust HashMap?
- How to get an element from a HashSet in Rust?
- How to implement PartialEq for a Rust HashMap?
- How to convert the keys of a Rust HashMap to a vector?
See more codes...