2018-07-28 15:34:52 +00:00
|
|
|
#![allow(clippy::write_literal)]
|
|
|
|
#![warn(clippy::write_with_newline)]
|
2018-04-05 03:46:39 +00:00
|
|
|
|
|
|
|
use std::io::Write;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut v = Vec::new();
|
|
|
|
|
|
|
|
// These should fail
|
|
|
|
write!(&mut v, "Hello\n");
|
|
|
|
write!(&mut v, "Hello {}\n", "world");
|
2018-08-07 20:01:10 +00:00
|
|
|
write!(&mut v, "Hello {} {}\n", "world", "#2");
|
2018-04-05 03:46:39 +00:00
|
|
|
write!(&mut v, "{}\n", 1265);
|
|
|
|
|
|
|
|
// These should be fine
|
|
|
|
write!(&mut v, "");
|
|
|
|
write!(&mut v, "Hello");
|
|
|
|
writeln!(&mut v, "Hello");
|
|
|
|
writeln!(&mut v, "Hello\n");
|
|
|
|
writeln!(&mut v, "Hello {}\n", "world");
|
|
|
|
write!(&mut v, "Issue\n{}", 1265);
|
|
|
|
write!(&mut v, "{}", 1265);
|
|
|
|
write!(&mut v, "\n{}", 1275);
|
2018-08-07 20:01:10 +00:00
|
|
|
write!(&mut v, "\n\n");
|
|
|
|
write!(&mut v, "like eof\n\n");
|
|
|
|
write!(&mut v, "Hello {} {}\n\n", "world", "#2");
|
2018-09-06 10:55:04 +00:00
|
|
|
writeln!(&mut v, "\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126
|
|
|
|
writeln!(&mut v, "\nbla\n\n"); // #3126
|
2018-12-11 06:28:25 +00:00
|
|
|
|
|
|
|
// Escaping
|
|
|
|
write!(&mut v, "\\n"); // #3514
|
|
|
|
write!(&mut v, "\\\n");
|
|
|
|
write!(&mut v, "\\\\n");
|
2018-04-05 03:46:39 +00:00
|
|
|
}
|