| 1 |
use std::io; |
| 2 |
use std::process; |
| 3 |
|
| 4 |
use same_file::Handle; |
| 5 |
|
| 6 |
fn main() { |
| 7 |
if let Err(err) = run() { |
| 8 |
println!("{}", err); |
| 9 |
process::exit(1); |
| 10 |
} |
| 11 |
} |
| 12 |
|
| 13 |
fn run() -> io::Result<()> { |
| 14 |
// Run with `cargo run --example is_stderr 2> examples/stderr` to see |
| 15 |
// interesting output. |
| 16 |
let candidates = &[ |
| 17 |
"examples/is_same_file.rs", |
| 18 |
"examples/is_stderr.rs", |
| 19 |
"examples/stderr", |
| 20 |
]; |
| 21 |
let stderr_handle = Handle::stderr()?; |
| 22 |
for candidate in candidates { |
| 23 |
let handle = Handle::from_path(candidate)?; |
| 24 |
if stderr_handle == handle { |
| 25 |
println!("{:?} is stderr!", candidate); |
| 26 |
} else { |
| 27 |
println!("{:?} is NOT stderr!", candidate); |
| 28 |
} |
| 29 |
} |
| 30 |
Ok(()) |
| 31 |
} |