Hello world/Standard error: Difference between revisions

→‎{{header|Rust}}: Added alternative method
(→‎{{header|Rust}}: Added alternative method)
Line 709:
 
fn main() {
writeln!(&mut io::stderr(), "Goodbye, world!").expect("Could not write to stderr");
// writeln! supports formatted strings so the following works as well
let goodbye = "Goodbye";
let world = "world";
writeln!(&mut io::stderr(), "{}, {}!", goodbye, world).expect("Could not write to stderr");
}
</lang>
 
or
<lang rust> use std::io::{self, Write};
fn main() {
io::stderr().write(b"Goodbye, world!").expect("Could not write to stderr");
// With some finagling, you can do a formatted string here as well
let goodbye = "Goodbye";
let world = "world";
io::stderr().write(&*format!("{}, {}!", goodbye, world).as_bytes()).expect("Could not write to stderr");
// Clearly, if you want formatted strings there's no reason not to just use writeln!
}
 
=={{header|Salmon}}==