#error #io-error #emulation #wrong #perror

program

Program: provide a rust analogue to C's perror

3 releases (breaking)

0.3.0 Apr 4, 2020
0.2.0 Apr 4, 2020
0.1.0 Mar 28, 2020

#2 in #wrong

Unlicense

4KB

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!

lib.rs:

Program provides a single divergent function (perror) to emulate C's perror

No runtime deps