From a733ece26e34403cd962b8ac109d2cb06748f330 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Thu, 7 Jan 2021 16:38:28 +0900 Subject: [PATCH] Suppress clippy --- plume-models/src/search/actor.rs | 34 +++++++++++++++++------------ plume-models/src/search/searcher.rs | 6 ++--- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/plume-models/src/search/actor.rs b/plume-models/src/search/actor.rs index 99769f60..e8b2f012 100644 --- a/plume-models/src/search/actor.rs +++ b/plume-models/src/search/actor.rs @@ -21,13 +21,13 @@ impl Actor for SearchActor { type Msg = PostEvent; fn pre_start(&mut self, ctx: &Context) { - &POST_CHAN.tell( + POST_CHAN.tell( Subscribe { actor: Box::new(ctx.myself()), topic: "*".into(), }, None, - ); + ) } fn recv(&mut self, _ctx: &Context, msg: Self::Msg, _sender: Sender) { @@ -36,22 +36,28 @@ impl Actor for SearchActor { match msg { PostPublished(post) => { let conn = self.conn.get(); - if conn.is_ok() { - self.searcher - .add_document(&conn.unwrap(), &post) - .unwrap_or_else(|e| error!("{:?}", e)); - } else { - error!("Failed to get database connection"); + match conn { + Ok(_) => { + self.searcher + .add_document(&conn.unwrap(), &post) + .unwrap_or_else(|e| error!("{:?}", e)); + }, + _ => { + error!("Failed to get database connection"); + } } } PostUpdated(post) => { let conn = self.conn.get(); - if conn.is_ok() { - self.searcher - .update_document(&conn.unwrap(), &post) - .unwrap_or_else(|e| error!("{:?}", e)); - } else { - error!("Failed to get database connection"); + match conn { + Ok(_) => { + self.searcher + .update_document(&conn.unwrap(), &post) + .unwrap_or_else(|e| error!("{:?}", e)); + }, + _ => { + error!("Failed to get database connection"); + } } } PostDeleted(post) => self.searcher.delete_document(&post), diff --git a/plume-models/src/search/searcher.rs b/plume-models/src/search/searcher.rs index 7ea01c59..d4ebb642 100644 --- a/plume-models/src/search/searcher.rs +++ b/plume-models/src/search/searcher.rs @@ -90,7 +90,7 @@ impl Searcher { } open_searcher = Self::open(path, tokenizers); } - let searcher = match open_searcher { + match open_searcher { Ok(s) => s, Err(Error::Search(e)) => match e { SearcherError::WriteLockAcquisitionError => panic!( @@ -118,9 +118,7 @@ Then try to restart Plume e => Err(e).unwrap(), }, _ => panic!("Unexpected error while opening search index"), - }; - - searcher + } } pub fn create(path: &dyn AsRef, tokenizers: &SearchTokenizerConfig) -> Result {