@@ -3,16 +3,14 @@ use proc_macro2::Ident;
33use quote:: { quote, ToTokens } ;
44use syn:: { parse_macro_input, Data , DataStruct , DeriveInput , Fields } ;
55
6- mod supported_maps {
6+ /// Returns `true` if the `type_string` provided is a type of a map
7+ /// supported by the [`crate::InfoSection`].
8+ pub fn is_supported_map ( type_string : & str ) -> bool {
79 /// A list of supported maps which can be converted to a dictionary for
810 /// the [`redis_module::InfoContext`].
911 const ALL : [ & str ; 2 ] = [ "BTreeMap" , "HashMap" ] ;
1012
11- /// Returns `true` if the `type_string` provided is a type of a map
12- /// supported by the [`crate::InfoSection`].
13- pub fn is_supported ( type_string : & str ) -> bool {
14- ALL . iter ( ) . any ( |m| type_string. contains ( & m. to_lowercase ( ) ) )
15- }
13+ ALL . iter ( ) . any ( |m| type_string. contains ( & m. to_lowercase ( ) ) )
1614}
1715
1816/// Generate a [`From`] implementation for this struct so that it is
@@ -38,9 +36,8 @@ fn struct_info_section(struct_name: Ident, struct_data: DataStruct) -> TokenStre
3836 . named
3937 . into_iter ( )
4038 . map ( |v| {
41- let is_dictionary = supported_maps:: is_supported (
42- & v. ty . clone ( ) . into_token_stream ( ) . to_string ( ) . to_lowercase ( ) ,
43- ) ;
39+ let is_dictionary =
40+ is_supported_map ( & v. ty . clone ( ) . into_token_stream ( ) . to_string ( ) . to_lowercase ( ) ) ;
4441 let name = v. ident . ok_or (
4542 "Structs with unnamed fields are not supported by the InfoSection." . to_owned ( ) ,
4643 ) ?;
0 commit comments