some derive cleanup

This commit is contained in:
Robin Appelman 2023-03-07 22:44:05 +01:00
commit c06e09e691
5 changed files with 58 additions and 49 deletions

View file

@ -6,8 +6,9 @@ mod event;
use crate::event::Event;
use proc_macro2::TokenStream;
use std::fmt::Debug;
use syn::{parse_macro_input, DeriveInput, Result};
use quote::ToTokens;
use std::fmt::{Debug, Display};
use syn::{parse_macro_input, DeriveInput, Error, Result};
/// Derive the `Event` trait for a struct
#[proc_macro_derive(Event, attributes(event))]
@ -36,3 +37,7 @@ trait Derivable {
trait DeriveParams: Sized + Debug {
fn parse(input: &DeriveInput) -> Result<Self>;
}
fn err<R, T: ToTokens, U: Display>(msg: U, span: T) -> Result<R> {
return Err(Error::new_spanned(&span, msg));
}