-
-
Save remram44/2e3a755b4107552723c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io; | |
use std::io::Write; | |
fn main() { | |
let output = &"hello"; | |
loop { | |
match write!(&mut io::stdout(), "{}\n", output) { | |
Ok(_) => {}, | |
Err(e) => { | |
if e.kind() == io::ErrorKind::BrokenPipe { | |
write!(&mut io::stderr(), "breaking\n").unwrap(); | |
break | |
} else { | |
panic!("My {}", e) | |
} | |
}, | |
} | |
} | |
write!(&mut io::stderr(), "got out of the loop alive\n").unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment