From aa17ece012fa415c5bea487a8f26b1c44bef4422 Mon Sep 17 00:00:00 2001 From: Aleksei Voronov Date: Fri, 22 Sep 2023 17:15:48 +0200 Subject: [PATCH] Fix clippy lints Nothing major here tbh --- src/algos.rs | 5 ++--- src/processes/post_indexer.rs | 4 ++-- src/services/ai.rs | 2 +- src/services/bluesky/client.rs | 4 ++-- src/services/bluesky/streaming.rs | 11 +++-------- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/algos.rs b/src/algos.rs index a1d6902..ca89486 100644 --- a/src/algos.rs +++ b/src/algos.rs @@ -48,15 +48,14 @@ impl Algos { } } +#[derive(Default)] pub struct AlgosBuilder { algos: AlgosMap, } impl AlgosBuilder { pub fn new() -> Self { - Self { - algos: AlgosMap::new(), - } + Default::default() } pub fn add(mut self, name: &str, algo: T) -> Self { diff --git a/src/processes/post_indexer.rs b/src/processes/post_indexer.rs index 74eb9a8..15be6ce 100644 --- a/src/processes/post_indexer.rs +++ b/src/processes/post_indexer.rs @@ -49,7 +49,7 @@ impl PostIndexer { info!("Subscribing with cursor {:?}", cursor); - Ok(self.bluesky.subscribe_to_operations(self, cursor).await?) + self.bluesky.subscribe_to_operations(self, cursor).await } } @@ -70,7 +70,7 @@ impl CommitProcessor for PostIndexer { info!("Received insertable post from {author_did}: {text}"); self.database - .insert_profile_if_it_doesnt_exist(&author_did) + .insert_profile_if_it_doesnt_exist(author_did) .await?; self.database.insert_post(author_did, cid, uri).await?; diff --git a/src/services/ai.rs b/src/services/ai.rs index 2c23955..71e7eae 100644 --- a/src/services/ai.rs +++ b/src/services/ai.rs @@ -36,6 +36,6 @@ impl AI { let response = self.chat_gpt_client.chat(chat_input).await?; // TODO: Error handling? - return Ok(response.choices[0].message.content.to_lowercase()); + Ok(response.choices[0].message.content.to_lowercase()) } } diff --git a/src/services/bluesky/client.rs b/src/services/bluesky/client.rs index 5b03c89..6eaffb9 100644 --- a/src/services/bluesky/client.rs +++ b/src/services/bluesky/client.rs @@ -125,8 +125,8 @@ impl Bluesky { }; Ok(ProfileDetails { - display_name: profile.display_name.unwrap_or_else(String::new), - description: profile.description.unwrap_or_else(String::new), + display_name: profile.display_name.unwrap_or_default(), + description: profile.description.unwrap_or_default(), }) } diff --git a/src/services/bluesky/streaming.rs b/src/services/bluesky/streaming.rs index 28fd76b..d73755b 100644 --- a/src/services/bluesky/streaming.rs +++ b/src/services/bluesky/streaming.rs @@ -33,7 +33,7 @@ pub enum Operation { } pub async fn handle_message(message: &[u8], processor: &P) -> Result<()> { - let commit = match parse_commit_from_message(&message)? { + let commit = match parse_commit_from_message(message)? { Some(commit) => commit, None => return Ok(()), }; @@ -43,7 +43,7 @@ pub async fn handle_message(message: &[u8], processor: &P) - processor .process_commit(&CommitDetails { seq: commit.seq, - operations: operations, + operations, }) .await?; @@ -77,12 +77,7 @@ async fn extract_operations(commit: &Commit) -> Result> { operations.push(match op.action.as_str() { "create" => Operation::CreatePost { - languages: record - .langs - .unwrap_or_else(Vec::new) - .iter() - .cloned() - .collect(), + languages: record.langs.unwrap_or_default().iter().cloned().collect(), text: record.text, author_did: commit.repo.clone(), cid: op