This language bar is your friend. Select your favorite languages!
Edit summary for version 39 :
[Rust] More idiomatic way

Version 38

Version 39

Idiom #59 Write to standard error stream

Print the message "x is negative" to standard error (stderr), with integer x value substitution (e.g. "-2 is negative").

Idiom #59 Write to standard error stream

Print the message "x is negative" to standard error (stderr), with integer x value substitution (e.g. "-2 is negative").

Imports
use std::io::stderr;
use std::io::Write;
Imports

					
				
Code
writeln!(&mut stderr(), "{} is negative", x).unwrap();
Code
eprintln!("{} is negative", x);
Comments bubble
Please note that writing to `stderr` can fail—therefor the `unwrap`.
Comments bubble
Please note that writing to `stderr` can fail—therefor the `unwrap`.
Origin
http://stackoverflow.com/a/27590832/1254484
Demo URL
https://play.rust-lang.org/?code=use%20std%3A%3Aio%3A%3Astderr%3B%0Ause%20std%3A%3Aio%3A%3AWrite%3B%0A%0Afn%20main()%20%7B%0A%20%20%20%20let%20x%20%3D%20-2%3B%0A%20%20%20%20writeln!(%26mut%20stderr()%2C%20%22%7B%7D%20is%20negative%22%2C%20x).unwrap()%3B%0A%7D&version=stable