setup clippy and make a pass on code

This commit is contained in:
Quentin de Quelen 2020-01-31 10:50:28 +01:00 committed by qdequele
parent ea2a64a504
commit 2143226f04
No known key found for this signature in database
GPG Key ID: B3F0A000EBF11745
6 changed files with 14 additions and 12 deletions

View File

@ -108,7 +108,7 @@ impl Data {
let api_key = opt.api_key.clone(); let api_key = opt.api_key.clone();
let server_pid = sysinfo::get_current_pid().unwrap(); let server_pid = sysinfo::get_current_pid().unwrap();
let db = Arc::new(Database::open_or_create(opt.db_path.clone()).unwrap()); let db = Arc::new(Database::open_or_create(opt.db_path).unwrap());
let inner_data = DataInner { let inner_data = DataInner {
db: db.clone(), db: db.clone(),

View File

@ -1,3 +1,5 @@
#![allow(clippy::or_fun_call)]
pub mod data; pub mod data;
pub mod error; pub mod error;
pub mod helpers; pub mod helpers;

View File

@ -44,7 +44,7 @@ pub async fn delete_document(ctx: Request<Data>) -> SResult<Response> {
let index = ctx.index()?; let index = ctx.index()?;
let identifier = ctx.identifier()?; let identifier = ctx.identifier()?;
let document_id = meilisearch_core::serde::compute_document_id(identifier.clone()); let document_id = meilisearch_core::serde::compute_document_id(identifier);
let db = &ctx.state().db; let db = &ctx.state().db;
let mut update_writer = db.update_write_txn()?; let mut update_writer = db.update_write_txn()?;
let mut documents_deletion = index.documents_deletion(); let mut documents_deletion = index.documents_deletion();
@ -69,7 +69,7 @@ pub async fn get_all_documents(ctx: Request<Data>) -> SResult<Response> {
ctx.is_allowed(DocumentsRead)?; ctx.is_allowed(DocumentsRead)?;
let index = ctx.index()?; let index = ctx.index()?;
let query: BrowseQuery = ctx.query().unwrap_or(BrowseQuery::default()); let query: BrowseQuery = ctx.query().unwrap_or_default();
let offset = query.offset.unwrap_or(0); let offset = query.offset.unwrap_or(0);
let limit = query.limit.unwrap_or(20); let limit = query.limit.unwrap_or(20);
@ -115,7 +115,7 @@ fn find_identifier(document: &IndexMap<String, Value>) -> Option<String> {
return Some(key.to_string()); return Some(key.to_string());
} }
} }
return None; None
} }
#[derive(Default, Deserialize)] #[derive(Default, Deserialize)]

View File

@ -159,7 +159,7 @@ pub async fn create_index(mut ctx: Request<Data>) -> SResult<Response> {
writer.commit()?; writer.commit()?;
let response_body = IndexCreateResponse { let response_body = IndexCreateResponse {
name: name, name,
uid, uid,
created_at, created_at,
updated_at, updated_at,

View File

@ -64,7 +64,7 @@ pub async fn search_with_url_query(ctx: Request<Data>) -> SResult<Response> {
let attributes_to_crop = schema let attributes_to_crop = schema
.displayed_name() .displayed_name()
.iter() .iter()
.map(|attr| (attr.to_string(), crop_length)) .map(|attr| ((*attr).to_string(), crop_length))
.collect(); .collect();
search_builder.attributes_to_crop(attributes_to_crop); search_builder.attributes_to_crop(attributes_to_crop);
} else { } else {
@ -81,7 +81,7 @@ pub async fn search_with_url_query(ctx: Request<Data>) -> SResult<Response> {
schema schema
.displayed_name() .displayed_name()
.iter() .iter()
.map(|s| s.to_string()) .map(|s| (*s).to_string())
.collect() .collect()
} else { } else {
attributes_to_highlight attributes_to_highlight

View File

@ -1,5 +1,5 @@
use meilisearch_core::settings::{Settings, SettingsUpdate, UpdateState}; use meilisearch_core::settings::{Settings, SettingsUpdate, UpdateState};
use serde::{Deserialize, Serialize}; use serde::Deserialize;
use std::collections::{BTreeMap, BTreeSet, HashSet}; use std::collections::{BTreeMap, BTreeSet, HashSet};
use tide::{Request, Response}; use tide::{Request, Response};
@ -57,10 +57,10 @@ pub async fn get_all(ctx: Request<Data>) -> SResult<Response> {
let identifier = schema.clone().map(|s| s.identifier().to_owned()); let identifier = schema.clone().map(|s| s.identifier().to_owned());
let searchable_attributes = schema let searchable_attributes = schema
.clone() .clone()
.map(|s| s.indexed_name().iter().map(|s| s.to_string()).collect()); .map(|s| s.indexed_name().iter().map(|s| (*s).to_string()).collect());
let displayed_attributes = schema let displayed_attributes = schema
.clone() .clone()
.map(|s| s.displayed_name().iter().map(|s| s.to_string()).collect()); .map(|s| s.displayed_name().iter().map(|s| (*s).to_string()).collect());
let index_new_fields = schema.map(|s| s.index_new_fields()); let index_new_fields = schema.map(|s| s.index_new_fields());
let settings = Settings { let settings = Settings {
@ -268,7 +268,7 @@ pub async fn get_searchable(ctx: Request<Data>) -> SResult<Response> {
let schema = index.main.schema(&reader)?; let schema = index.main.schema(&reader)?;
let searchable_attributes: Option<HashSet<String>> = let searchable_attributes: Option<HashSet<String>> =
schema.map(|s| s.indexed_name().iter().map(|i| i.to_string()).collect()); schema.map(|s| s.indexed_name().iter().map(|i| (*i).to_string()).collect());
Ok(tide::Response::new(200) Ok(tide::Response::new(200)
.body_json(&searchable_attributes) .body_json(&searchable_attributes)
@ -322,7 +322,7 @@ pub async fn displayed(ctx: Request<Data>) -> SResult<Response> {
let schema = index.main.schema(&reader)?; let schema = index.main.schema(&reader)?;
let displayed_attributes: Option<HashSet<String>> = let displayed_attributes: Option<HashSet<String>> =
schema.map(|s| s.displayed_name().iter().map(|i| i.to_string()).collect()); schema.map(|s| s.displayed_name().iter().map(|i| (*i).to_string()).collect());
Ok(tide::Response::new(200) Ok(tide::Response::new(200)
.body_json(&displayed_attributes) .body_json(&displayed_attributes)