Crates.io | program |
lib.rs | program |
version | 0.3.0 |
source | src |
created_at | 2020-03-28 04:38:46.099077 |
updated_at | 2020-04-04 04:12:48.663151 |
description | Program: provide a rust analogue to C's perror |
homepage | |
repository | https://github.com/nickrtorres/program |
max_upload_size | |
id | 223724 |
size | 4,364 |
Program
emulates C's perror
.
use program::perror;
use std::io::{self};
fn print_msg(_: &str) -> io::Result<()> {
Err(io::Error::new(
io::ErrorKind::Other,
"something went wrong!",
))
}
fn main() {
if let Err(e) = print_msg("Hello, world!") {
perror(e);
}
}
$ cargo run
Compiling example v0.1.0 (/root/example)
Finished dev [unoptimized + debuginfo] target(s) in 0.34s
Running `target/debug/example`
example: something went wrong!