2 #![warn(clippy::explicit_write)]
3 #![allow(unused_imports)]
4 #![allow(clippy::uninlined_format_args)]
6 fn stdout() -> String {
10 fn stderr() -> String {
32 println!("test\ntest");
33 eprintln!("test\ntest");
36 eprintln!("with {}", value);
37 eprintln!("with {} {}", 2, value);
38 eprintln!("with {value}");
39 eprintln!("macro arg {}", one!());
41 eprintln!("{:w$}", value, w = width);
43 // these should not warn, different destination
46 let mut s = String::new();
47 write!(s, "test").unwrap();
48 write!(s, "test").unwrap();
49 writeln!(s, "test").unwrap();
50 writeln!(s, "test").unwrap();
51 s.write_fmt(format_args!("test")).unwrap();
52 s.write_fmt(format_args!("test")).unwrap();
53 write!(stdout(), "test").unwrap();
54 write!(stderr(), "test").unwrap();
55 writeln!(stdout(), "test").unwrap();
56 writeln!(stderr(), "test").unwrap();
57 stdout().write_fmt(format_args!("test")).unwrap();
58 stderr().write_fmt(format_args!("test")).unwrap();
60 // these should not warn, no unwrap
63 std::io::stdout().write_fmt(format_args!("test")).expect("no stdout");
64 std::io::stderr().write_fmt(format_args!("test")).expect("no stderr");