Crates.io | quick_from |
lib.rs | quick_from |
version | 0.2.0 |
source | src |
created_at | 2021-06-11 23:28:08.630249 |
updated_at | 2021-11-03 22:35:30.986194 |
description | A derive macro for quickly implementing From on on enum variants that wrap other types. |
homepage | |
repository | https://github.com/ear7h/quick-from |
max_upload_size | |
id | 409155 |
size | 11,569 |
quick_from
A derive macro for quickly implementing From
on on enum variants that wrap
other types.
#[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)?)
}