quick_from

Crates.ioquick_from
lib.rsquick_from
version0.2.0
sourcesrc
created_at2021-06-11 23:28:08.630249
updated_at2021-11-03 22:35:30.986194
descriptionA derive macro for quickly implementing From on on enum variants that wrap other types.
homepage
repositoryhttps://github.com/ear7h/quick-from
max_upload_size
id409155
size11,569
Julio (ear7h)

documentation

README

quick_from

A derive macro for quickly implementing From on on enum variants that wrap other types.

Example

#[macro_use]
extern crate quick_from;

use std::{io, fs};

#[derive(QuickFrom)]
enum Error {
    InvalidInput,

    #[quick_from]
    Io(io::Error),
}

fn my_read(s : &str) -> Result<Vec<u8>, Error> {
    if s.len() == 0 {
        return Err(Error::InvalidInput)
    }

    Ok(fs::read(s)?)
}
Commit count: 2

cargo fmt