1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

impl Display for registry things

This commit is contained in:
mat 2022-08-27 15:17:18 -05:00
parent 4f209ee622
commit d373ee5482

View file

@ -108,5 +108,24 @@ pub fn registry(input: TokenStream) -> TokenStream {
}
});
// Display that uses registry ids
let mut display_items = quote! {};
for item in input.items.iter() {
let name = &item.name;
let id = &item.id;
display_items.extend(quote! {
Self::#name => write!(f, #id),
});
}
generated.extend(quote! {
impl std::fmt::Display for #name {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
#display_items
}
}
}
});
generated.into()
}