@@ -43,8 +43,8 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result<TokenStream> {
4343 } = extract_attrs ( attrs) ?;
4444 let collection_name = collection_name. unwrap_or_else ( || ident. to_string ( ) . to_lowercase ( ) ) ;
4545
46- if let Some ( ref sorting_field) = default_sorting_field {
47- if !fields. iter ( ) . any ( |field|
46+ if let Some ( ref sorting_field) = default_sorting_field
47+ && !fields. iter ( ) . any ( |field|
4848 // At this point we are sure that this field is a named field.
4949 field. ident . as_ref ( ) . unwrap ( ) == sorting_field)
5050 {
@@ -55,7 +55,6 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result<TokenStream> {
5555 ) ,
5656 ) ) ;
5757 }
58- }
5958
6059 let typesense_fields = fields
6160 . iter ( )
@@ -98,19 +97,16 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result<TokenStream> {
9897
9998// Get the inner type for a given wrapper
10099fn ty_inner_type < ' a > ( ty : & ' a syn:: Type , wrapper : & ' static str ) -> Option < & ' a syn:: Type > {
101- if let syn:: Type :: Path ( p) = ty {
102- if p. path . segments . len ( ) == 1 && p. path . segments [ 0 ] . ident == wrapper {
103- if let syn:: PathArguments :: AngleBracketed ( ref inner_ty) = p. path . segments [ 0 ] . arguments {
104- if inner_ty. args . len ( ) == 1 {
100+ if let syn:: Type :: Path ( p) = ty
101+ && p. path . segments . len ( ) == 1 && p. path . segments [ 0 ] . ident == wrapper
102+ && let syn:: PathArguments :: AngleBracketed ( ref inner_ty) = p. path . segments [ 0 ] . arguments
103+ && inner_ty. args . len ( ) == 1 {
105104 // len is 1 so this should not fail
106105 let inner_ty = inner_ty. args . first ( ) . unwrap ( ) ;
107106 if let syn:: GenericArgument :: Type ( t) = inner_ty {
108107 return Some ( t) ;
109108 }
110109 }
111- }
112- }
113- }
114110 None
115111}
116112
@@ -231,8 +227,8 @@ fn to_typesense_field_type(field: &Field) -> syn::Result<proc_macro2::TokenStrea
231227 . attrs
232228 . iter ( )
233229 . filter_map ( |attr| {
234- if attr. path . segments . len ( ) == 1 && attr. path . segments [ 0 ] . ident == "typesense" {
235- if let Some ( proc_macro2:: TokenTree :: Group ( g) ) =
230+ if attr. path . segments . len ( ) == 1 && attr. path . segments [ 0 ] . ident == "typesense"
231+ && let Some ( proc_macro2:: TokenTree :: Group ( g) ) =
236232 attr. tokens . clone ( ) . into_iter ( ) . next ( )
237233 {
238234 let mut tokens = g. stream ( ) . into_iter ( ) ;
@@ -267,7 +263,6 @@ fn to_typesense_field_type(field: &Field) -> syn::Result<proc_macro2::TokenStrea
267263 }
268264 return Some ( Ok ( ( ) ) ) ;
269265 }
270- }
271266 None
272267 } )
273268 . collect :: < syn:: Result < Vec < _ > > > ( ) ?;
0 commit comments