2 unstable releases
0.2.0 | Nov 3, 2021 |
---|---|
0.1.0 | Jun 11, 2021 |
#69 in #wrap
31 downloads per month
6KB
55 lines
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)?)
}
Dependencies
~1.5MB
~36K SLoC