mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
23 lines
640 B
Rust
23 lines
640 B
Rust
use std::env::args;
|
|
use std::fs::File;
|
|
use std::io::{stdout, Write, BufWriter};
|
|
|
|
fn main() {
|
|
let mut args = args();
|
|
let _ = args.next();
|
|
let dest = args.next();
|
|
|
|
let h1; let h2; let h3;
|
|
|
|
let fp: &dyn Write = match dest {
|
|
Some(path) => { h1 = File::create(path).unwrap(); &h1 },
|
|
None => { h2 = stdout(); h3 = h2.lock(); &h3 }
|
|
};
|
|
|
|
let fp = BufWriter::new(fp);
|
|
//~^ ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
|
|
//~| ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
|
|
|
|
writeln!(fp, "hello world").unwrap(); //~ ERROR the method
|
|
}
|