i have a enum like
#[derive(Normal)]
pub enum NormalError{
#[msg = "{name} not found"]
NotFound{name: &'static str},
#[msg = "invalid {}"]
InvalidParameter(&'static str),
#[msg = "invalid"]
InvalidCredential
}
and i want to make a proc macro to impl a function to print message like code below:
impl xxx for Normal{
fn print(&self) -> String{
match self{
NormalError::NotFound{name} => format!("{name} not found"),
NormalError::InvalidParameter(t) => format!("{} not found", t.0),
NormalError::InvalidCredential => format!("invalid"),
}
}
}
but i failed to process the field of variant because the syn::Field
cannot convert to syn::Arm
easily. Is there any way to solve this problem?