From 18238dd6cb509b038f02a46048ddf6f07f4f2255 Mon Sep 17 00:00:00 2001 From: Arthur Zucker Date: Sun, 16 Jun 2024 18:50:06 +0200 Subject: [PATCH] let's just go with this no it's not optimal but I need to go --- tokenizers/display_derive/src/lib.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tokenizers/display_derive/src/lib.rs b/tokenizers/display_derive/src/lib.rs index 315135297..2114eafec 100644 --- a/tokenizers/display_derive/src/lib.rs +++ b/tokenizers/display_derive/src/lib.rs @@ -46,7 +46,8 @@ fn generate_fmt_impl_for_struct( attrs: &Option, ) -> proc_macro2::TokenStream { let fields = &data_struct.fields; - + // TODO I am stuck here for now hehe. + // Basically we need to produce the body that will be used. // Generate field formatting expressions let field_formats: Vec<_> = fields .iter() @@ -85,13 +86,9 @@ fn generate_fmt_impl_for_struct( // Generate the final implementation of Display trait for the struct quote! { - impl std::fmt::Display for #ident { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, "{}(", stringify!(#ident))?; - #(#field_formats)* - write!(f, ")") - } - } + write!(f, "{}(", stringify!(#ident))?; + #field_formats + write!(f, ")") } } fn generate_fmt_impl_for_enum(