program

Crates.ioprogram
lib.rsprogram
version0.3.0
sourcesrc
created_at2020-03-28 04:38:46.099077
updated_at2020-04-04 04:12:48.663151
descriptionProgram: provide a rust analogue to C's perror
homepage
repositoryhttps://github.com/nickrtorres/program
max_upload_size
id223724
size4,364
Nick Torres (nickrtorres)

documentation

README

Program

Program emulates C's perror.

Crates.io

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!
Commit count: 33

cargo fmt