11use super :: { index_type:: IndexType , AttributeMode , Settings } ;
22use proc_macro2:: { Ident , Span } ;
33use std:: collections:: HashMap ;
4- use syn:: { Data , DeriveInput , Fields , LitStr , ExprPath } ;
4+ use syn:: { Data , DeriveInput , ExprPath , Fields , LitStr } ;
55
66enum SortKeyPrefix {
77 Default ,
@@ -19,7 +19,7 @@ impl SortKeyPrefix {
1919 }
2020}
2121
22- const RESERVED_FIELD_NAMES : & ' static [ & ' static str ] = & [ "term" ] ;
22+ const RESERVED_FIELD_NAMES : & [ & str ] = & [ "term" ] ;
2323
2424pub ( crate ) struct SettingsBuilder {
2525 ident : Ident ,
@@ -162,28 +162,25 @@ impl SettingsBuilder {
162162 let has_partition_key_attr = field
163163 . attrs
164164 . iter ( )
165- . find ( |x| x. path ( ) . is_ident ( "partition_key" ) )
166- . is_some ( ) ;
165+ . any ( |x| x. path ( ) . is_ident ( "partition_key" ) ) ;
167166
168167 if !has_partition_key_attr {
169168 return Err ( syn:: Error :: new_spanned (
170169 field,
171- format ! ( "field named 'pk' must be annotated with #[partition_key]" ) ,
170+ "field named 'pk' must be annotated with #[partition_key]"
171+ . to_string ( ) ,
172172 ) ) ;
173173 }
174174 }
175175
176176 if field_name == "sk" {
177- let has_partition_key_attr = field
178- . attrs
179- . iter ( )
180- . find ( |x| x. path ( ) . is_ident ( "sort_key" ) )
181- . is_some ( ) ;
177+ let has_partition_key_attr =
178+ field. attrs . iter ( ) . any ( |x| x. path ( ) . is_ident ( "sort_key" ) ) ;
182179
183180 if !has_partition_key_attr {
184181 return Err ( syn:: Error :: new_spanned (
185182 field,
186- format ! ( "field named 'sk' must be annotated with #[sort_key]" ) ,
183+ "field named 'sk' must be annotated with #[sort_key]" . to_string ( ) ,
187184 ) ) ;
188185 }
189186 }
@@ -522,4 +519,4 @@ impl SettingsBuilder {
522519
523520 Ok ( ( ) )
524521 }
525- }
522+ }
0 commit comments