rust-clippy/tests/ui/write_with_newline.rs
2018-04-07 22:45:26 -07:00

25 lines
603 B
Rust

#![allow(write_literal)]
#![warn(write_with_newline)]
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");
write!(&mut v, "Hello {} {}\n\n", "world", "#2");
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);
}