kinderror

Crates.iokinderror
lib.rskinderror
version0.1.3
created_at2026-01-20 16:00:24.95959+00
updated_at2026-01-21 03:04:28.828158+00
descriptionAn io::Error style kind Error derive macro
homepage
repositoryhttps://github.com/Sherlock-Holo/kinderror
max_upload_size
id2056902
size18,172
Sherlock Holo (Sherlock-Holo)

documentation

README

kinderror

An io::Error style kind Error derive macro

Example

use kinderror::KindError;
use std::error::Error as _;

#[derive(KindError, Debug, Eq, PartialEq)]
#[kind_error(
    source = "std::io::Error",
    source_fn = true,
    new_vis = "pub",
    name = "Error",
    type_vis = "pub",
    kind_fn_vis = "pub",
    display = "hey, error kind: {kind:?}, source: {source}"
)]
enum ErrorKind {
    First,
    Second,
}

fn main() {
    let err = Error::new(ErrorKind::First, std::io::Error::other("first error"));
    assert_eq!(*err.kind(), ErrorKind::First);
    assert!(err.source().is_some());
}

License

MIT

Commit count: 8

cargo fmt