Skip to content

Commit 741b11a

Browse files
committed
fix fmt and typesense/lib.rs docs test
1 parent ea93b0a commit 741b11a

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

typesense/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! # Examples
99
//!
1010
//! ```
11-
//! #[cfg(any(feature = "tokio_test", target_arch = "wasm32"))]
11+
//! #[cfg(not(target_family = "wasm"))]
1212
//! {
1313
//! use serde::{Deserialize, Serialize};
1414
//! use typesense::document::Document;

typesense_derive/src/lib.rs

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result<TokenStream> {
4747
&& !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)
50-
{
51-
return Err(syn::Error::new_spanned(
52-
item_ts,
53-
format!(
54-
"defined default_sorting_field = \"{sorting_field}\" does not match with any field."
55-
),
56-
));
57-
}
50+
{
51+
return Err(syn::Error::new_spanned(
52+
item_ts,
53+
format!(
54+
"defined default_sorting_field = \"{sorting_field}\" does not match with any field."
55+
),
56+
));
57+
}
5858

5959
let typesense_fields = fields
6060
.iter()
@@ -98,15 +98,17 @@ fn impl_typesense_collection(item: ItemStruct) -> syn::Result<TokenStream> {
9898
// Get the inner type for a given wrapper
9999
fn ty_inner_type<'a>(ty: &'a syn::Type, wrapper: &'static str) -> Option<&'a syn::Type> {
100100
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 {
104-
// len is 1 so this should not fail
105-
let inner_ty = inner_ty.args.first().unwrap();
106-
if let syn::GenericArgument::Type(t) = inner_ty {
107-
return Some(t);
108-
}
109-
}
101+
&& p.path.segments.len() == 1
102+
&& p.path.segments[0].ident == wrapper
103+
&& let syn::PathArguments::AngleBracketed(ref inner_ty) = p.path.segments[0].arguments
104+
&& inner_ty.args.len() == 1
105+
{
106+
// len is 1 so this should not fail
107+
let inner_ty = inner_ty.args.first().unwrap();
108+
if let syn::GenericArgument::Type(t) = inner_ty {
109+
return Some(t);
110+
}
111+
}
110112
None
111113
}
112114

@@ -227,42 +229,40 @@ fn to_typesense_field_type(field: &Field) -> syn::Result<proc_macro2::TokenStrea
227229
.attrs
228230
.iter()
229231
.filter_map(|attr| {
230-
if attr.path.segments.len() == 1 && attr.path.segments[0].ident == "typesense"
232+
if attr.path.segments.len() == 1
233+
&& attr.path.segments[0].ident == "typesense"
231234
&& let Some(proc_macro2::TokenTree::Group(g)) =
232235
attr.tokens.clone().into_iter().next()
233-
{
234-
let mut tokens = g.stream().into_iter();
235-
match tokens.next() {
236-
Some(proc_macro2::TokenTree::Ident(ref i)) => {
237-
if i != "facet" {
238-
return Some(Err(syn::Error::new_spanned(
239-
i,
240-
format!("Unexpected token {i}. Did you mean `facet`?"),
241-
)));
242-
}
243-
}
244-
Some(ref tt) => {
245-
return Some(Err(syn::Error::new_spanned(
246-
tt,
247-
format!("Unexpected token {tt}. Did you mean `facet`?"),
248-
)));
249-
}
250-
None => {
236+
{
237+
let mut tokens = g.stream().into_iter();
238+
match tokens.next() {
239+
Some(proc_macro2::TokenTree::Ident(ref i)) => {
240+
if i != "facet" {
251241
return Some(Err(syn::Error::new_spanned(
252-
attr,
253-
"expected `facet`",
242+
i,
243+
format!("Unexpected token {i}. Did you mean `facet`?"),
254244
)));
255245
}
256246
}
257-
258-
if let Some(ref tt) = tokens.next() {
247+
Some(ref tt) => {
259248
return Some(Err(syn::Error::new_spanned(
260249
tt,
261-
"Unexpected token. Expected )",
250+
format!("Unexpected token {tt}. Did you mean `facet`?"),
262251
)));
263252
}
264-
return Some(Ok(()));
253+
None => {
254+
return Some(Err(syn::Error::new_spanned(attr, "expected `facet`")));
255+
}
265256
}
257+
258+
if let Some(ref tt) = tokens.next() {
259+
return Some(Err(syn::Error::new_spanned(
260+
tt,
261+
"Unexpected token. Expected )",
262+
)));
263+
}
264+
return Some(Ok(()));
265+
}
266266
None
267267
})
268268
.collect::<syn::Result<Vec<_>>>()?;

0 commit comments

Comments
 (0)