From 5c45a910cef66aa99376dc282409a79c4a38fc85 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Tue, 18 Feb 2025 22:01:47 +0100 Subject: [PATCH] Adds doc --- more_fields_macro/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/more_fields_macro/src/lib.rs b/more_fields_macro/src/lib.rs index 8f4aca3..4bfca29 100644 --- a/more_fields_macro/src/lib.rs +++ b/more_fields_macro/src/lib.rs @@ -1,6 +1,6 @@ // Workspace: more_fields_macro // File: more_fields_macro/src/lib.rs -//! A very simple proc macro in chage of giving a field iterator over ("name","sql_type") +//! A very simple proc macro in chage of giving a field slice over ("name","sql_type") //! This macro is a fork of the excellent work of : https://crates.io/crates/struct_iterable //! //! Other ressources include: @@ -57,15 +57,15 @@ pub fn derive_iterable(input: TokenStream) -> TokenStream { let name_of_static_str = struct_name.to_string().to_ascii_uppercase() + "_ATTR_SLICE"; let name_of_static = Ident::new(&name_of_static_str, Span::call_site().into()); - // static STATIC_FIELDS_OF_STRUCT_#struct_name: std::sync::LazyLock> = - // std::sync::LazyLock::new(|| vec![]); - // let expanded = quote! { + /// Derived implementation of a (attribute, type) slice + /// allowing a constant time serialisation & deserialisation into rusqlite const #name_of_static: &[(&str, &str)] = &[ #(#fields_iter),* ]; impl FieldsAsSlice for #struct_name { + /// Gives a precompiled slice of the &[(fields: &str, sqlite_type: &str)] fn attributes_slice<'a>() -> &'static [(&'static str, &'static str)] { #name_of_static }