Crates.io | ace_it |
lib.rs | ace_it |
version | 0.1.1 |
source | src |
created_at | 2023-01-24 13:56:38.182067 |
updated_at | 2023-01-25 01:26:28.741362 |
description | Macro to automate wrapping types into enums |
homepage | |
repository | https://github.com/VlaDexa/ace_it |
max_upload_size | |
id | 766687 |
size | 8,584 |
Just a small proc_macro to automatically generate From trait impls for each unnamed variant of an enum
Cargo.toml:
[dependencies]
ace_it = "0.1"
#[macro_use]
extern crate ace_it;
#[derive(Debug)]
#[ace_it]
enum Error {
Io(std::io::Error),
ParseInt(std::num::ParseIntError),
ParseFloat(std::num::ParseFloatError),
}
use std::io::Read;
fn read_int<R: Read>(reader: &mut R) -> Result<i32, Error> {
let mut buf = String::new();
reader.read_to_string(&mut buf)?;
Ok(buf.parse()?)
}