diff --git a/src/index.rs b/src/index.rs index 1514bd2..b23683c 100644 --- a/src/index.rs +++ b/src/index.rs @@ -96,7 +96,7 @@ impl Index { for term_frame in hpo_doc .entities() .iter() - .flat_map(fastobo::ast::EntityFrame::as_term) + .filter_map(fastobo::ast::EntityFrame::as_term) { let mut doc = tantivy::Document::default(); @@ -105,7 +105,11 @@ impl Index { ident_to_string(term_frame.id().as_inner().as_ref()), ); - for line in term_frame.clauses().iter().map(|l| l.as_inner()) { + for line in term_frame + .clauses() + .iter() + .map(fastobo::ast::Line::as_inner) + { match line { fastobo::ast::TermClause::Name(name) => { doc.add_field_value(schema.get_field("name")?, name.as_str()); diff --git a/src/server/actix_server/hpo_genes.rs b/src/server/actix_server/hpo_genes.rs index 47c2e2a..6403641 100644 --- a/src/server/actix_server/hpo_genes.rs +++ b/src/server/actix_server/hpo_genes.rs @@ -86,7 +86,6 @@ impl ResultEntry { .map(|term| ResultHpoTerm { term_id: term.id().to_string(), name: term.name().to_string(), - ..Default::default() }) .collect::>(); terms.sort(); diff --git a/src/server/actix_server/hpo_omims.rs b/src/server/actix_server/hpo_omims.rs index f5c8cb0..e03188f 100644 --- a/src/server/actix_server/hpo_omims.rs +++ b/src/server/actix_server/hpo_omims.rs @@ -111,7 +111,6 @@ impl ResultEntry { ResultHpoTerm { term_id: term.id().to_string(), name: term.name().to_string(), - ..Default::default() } }) .collect::>(); diff --git a/src/server/actix_server/hpo_terms.rs b/src/server/actix_server/hpo_terms.rs index e33b4bb..812b79d 100644 --- a/src/server/actix_server/hpo_terms.rs +++ b/src/server/actix_server/hpo_terms.rs @@ -137,12 +137,12 @@ impl ResultEntry { let definition = doc .get_all(field_def) - .flat_map(|f| f.as_text().map(|s| s.to_string())) + .filter_map(|f| f.as_text().map(std::string::ToString::to_string)) .collect::>(); - let definition = definition.first().map(|s| s.clone()); + let definition = definition.first().map(std::clone::Clone::clone); let synonyms = doc .get_all(field_synonym) - .flat_map(|f| f.as_text().map(|s| s.to_string())) + .filter_map(|f| f.as_text().map(std::string::ToString::to_string)) .collect::>(); let synonyms = if synonyms.is_empty() { None @@ -151,7 +151,7 @@ impl ResultEntry { }; let xrefs = doc .get_all(field_xref) - .flat_map(|f| f.as_text().map(|s| s.to_string())) + .filter_map(|f| f.as_text().map(std::string::ToString::to_string)) .collect::>(); let xrefs = if xrefs.is_empty() { None } else { Some(xrefs) }; @@ -199,6 +199,7 @@ struct Container { /// /// In the case that there is an error running the server. #[allow(clippy::unused_async)] +#[allow(clippy::too_many_lines)] #[get("/hpo/terms")] async fn handle( data: Data, @@ -277,8 +278,8 @@ async fn handle( query_parser.set_field_fuzzy(field_synonym, true, 1, true); query_parser }; - let index_query = query_parser.parse_query(&name).map_err(|e| { - eprintln!("{}", e); + let index_query = query_parser.parse_query(name).map_err(|e| { + eprintln!("{e}"); CustomError::new(anyhow::anyhow!("Error parsing query: {}", e)) })?; let top_docs = searcher diff --git a/src/server/mod.rs b/src/server/mod.rs index 973baeb..b84e7bc 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -150,7 +150,7 @@ pub fn run(args_common: &crate::common::Args, args: &Args) -> Result<(), anyhow: tracing::info!("Loading HPO OBO..."); let before_load_obo = std::time::Instant::now(); - let hpo_doc = fastobo::from_file(&format!("{}/{}", &args.path_hpo_dir, "hp.obo")) + let hpo_doc = fastobo::from_file(format!("{}/{}", &args.path_hpo_dir, "hp.obo")) .map_err(|e| anyhow::anyhow!("Error loading HPO OBO: {}", e))?; tracing::info!( "... done loading HPO OBO in {:?}",