Further reduce an async block

This commit is contained in:
Clément Renault 2023-11-28 14:23:32 +01:00
parent add2ceef67
commit 1575456594
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -46,8 +46,7 @@ pub async fn multi_search_with_post(
// Explicitly expect a `(ResponseError, usize)` for the error type rather than `ResponseError` only,
// so that `?` doesn't work if it doesn't use `with_index`, ensuring that it is not forgotten in case of code
// changes.
let search_results: Result<_, (ResponseError, usize)> = {
async {
let search_results: Result<_, (ResponseError, usize)> = async {
let mut search_results = Vec::with_capacity(queries.len());
for (query_index, (index_uid, mut query)) in
queries.into_iter().map(SearchQueryWithIndex::into_index_query).enumerate()
@ -59,8 +58,7 @@ pub async fn multi_search_with_post(
return Err(AuthenticationError::InvalidToken).with_index(query_index);
}
// Apply search rules from tenant token
if let Some(search_rules) =
index_scheduler.filters().get_index_search_rules(&index_uid)
if let Some(search_rules) = index_scheduler.filters().get_index_search_rules(&index_uid)
{
add_search_rules(&mut query, search_rules);
}
@ -88,7 +86,6 @@ pub async fn multi_search_with_post(
}
Ok(search_results)
}
}
.await;
if search_results.is_ok() {