Fix clippy lints

Nothing major here tbh
This commit is contained in:
Aleksei Voronov 2023-09-22 17:15:48 +02:00
parent 83bede52ce
commit aa17ece012
5 changed files with 10 additions and 16 deletions

View File

@ -48,15 +48,14 @@ impl Algos {
} }
} }
#[derive(Default)]
pub struct AlgosBuilder { pub struct AlgosBuilder {
algos: AlgosMap, algos: AlgosMap,
} }
impl AlgosBuilder { impl AlgosBuilder {
pub fn new() -> Self { pub fn new() -> Self {
Self { Default::default()
algos: AlgosMap::new(),
}
} }
pub fn add<T: Algo + Send + Sync + 'static>(mut self, name: &str, algo: T) -> Self { pub fn add<T: Algo + Send + Sync + 'static>(mut self, name: &str, algo: T) -> Self {

View File

@ -49,7 +49,7 @@ impl PostIndexer {
info!("Subscribing with cursor {:?}", cursor); 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}"); info!("Received insertable post from {author_did}: {text}");
self.database self.database
.insert_profile_if_it_doesnt_exist(&author_did) .insert_profile_if_it_doesnt_exist(author_did)
.await?; .await?;
self.database.insert_post(author_did, cid, uri).await?; self.database.insert_post(author_did, cid, uri).await?;

View File

@ -36,6 +36,6 @@ impl AI {
let response = self.chat_gpt_client.chat(chat_input).await?; let response = self.chat_gpt_client.chat(chat_input).await?;
// TODO: Error handling? // TODO: Error handling?
return Ok(response.choices[0].message.content.to_lowercase()); Ok(response.choices[0].message.content.to_lowercase())
} }
} }

View File

@ -125,8 +125,8 @@ impl Bluesky {
}; };
Ok(ProfileDetails { Ok(ProfileDetails {
display_name: profile.display_name.unwrap_or_else(String::new), display_name: profile.display_name.unwrap_or_default(),
description: profile.description.unwrap_or_else(String::new), description: profile.description.unwrap_or_default(),
}) })
} }

View File

@ -33,7 +33,7 @@ pub enum Operation {
} }
pub async fn handle_message<P: CommitProcessor>(message: &[u8], processor: &P) -> Result<()> { pub async fn handle_message<P: CommitProcessor>(message: &[u8], processor: &P) -> Result<()> {
let commit = match parse_commit_from_message(&message)? { let commit = match parse_commit_from_message(message)? {
Some(commit) => commit, Some(commit) => commit,
None => return Ok(()), None => return Ok(()),
}; };
@ -43,7 +43,7 @@ pub async fn handle_message<P: CommitProcessor>(message: &[u8], processor: &P) -
processor processor
.process_commit(&CommitDetails { .process_commit(&CommitDetails {
seq: commit.seq, seq: commit.seq,
operations: operations, operations,
}) })
.await?; .await?;
@ -77,12 +77,7 @@ async fn extract_operations(commit: &Commit) -> Result<Vec<Operation>> {
operations.push(match op.action.as_str() { operations.push(match op.action.as_str() {
"create" => Operation::CreatePost { "create" => Operation::CreatePost {
languages: record languages: record.langs.unwrap_or_default().iter().cloned().collect(),
.langs
.unwrap_or_else(Vec::new)
.iter()
.cloned()
.collect(),
text: record.text, text: record.text,
author_did: commit.repo.clone(), author_did: commit.repo.clone(),
cid: op cid: op