From b82d968e49ffdba02e98b47cf3df1880552e290b Mon Sep 17 00:00:00 2001 From: rmanach Date: Sat, 22 Apr 2023 15:29:55 +0200 Subject: [PATCH] cargo clippy fix --- src/message/message.rs | 9 +++------ src/model/job.rs | 12 ++++++------ src/worker/worker.rs | 12 ++++++------ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/message/message.rs b/src/message/message.rs index 2331051..9119103 100644 --- a/src/message/message.rs +++ b/src/message/message.rs @@ -21,7 +21,7 @@ pub struct Body { impl Body { fn new(id: u32) -> Self { - Self { id: id } + Self { id } } fn get_id(&self) -> u32 { @@ -38,7 +38,7 @@ pub struct Message { impl Message { pub fn new(id: u32, subject: Subject) -> Self { Self { - subject: subject, + subject, body: Some(Body::new(id)), } } @@ -62,9 +62,6 @@ impl Message { } pub fn get_body_id(&self) -> Option { - match self.body { - Some(ref b) => Some(b.get_id()), - None => None, - } + self.body.as_ref().map(|b| b.get_id()) } } diff --git a/src/model/job.rs b/src/model/job.rs index ae5a26f..03e639e 100644 --- a/src/model/job.rs +++ b/src/model/job.rs @@ -22,8 +22,8 @@ pub struct Job { impl Job { pub fn new(id: i32, action: JobAction) -> Self { Self { - id: id, - action: action, + id, + action, status: RunnerStatus::Pending, } } @@ -34,13 +34,13 @@ impl Job { fn deploy(&mut self) -> Result { self.set_status(RunnerStatus::Running); - println!("{} {}", self.format_job(), "deploying..."); + println!("{} deploying...", self.format_job()); let wait = time::Duration::from_secs(5); thread::sleep(wait); self.set_status(RunnerStatus::Success); - println!("{} {}", self.format_job(), "deploy done"); + println!("{} deploy done", self.format_job()); Ok(Message::new( self.id.try_into().unwrap(), @@ -50,13 +50,13 @@ impl Job { fn check(&mut self) -> Result { self.set_status(RunnerStatus::Running); - println!("{} {}", self.format_job(), "checking..."); + println!("{} checking...", self.format_job()); let wait = time::Duration::from_millis(50); thread::sleep(wait); self.set_status(RunnerStatus::Success); - println!("{} {}", self.format_job(), "checking done"); + println!("{} checking done", self.format_job()); Ok(Message::empty()) } diff --git a/src/worker/worker.rs b/src/worker/worker.rs index 29d3056..9a2ccab 100644 --- a/src/worker/worker.rs +++ b/src/worker/worker.rs @@ -50,12 +50,12 @@ impl Worker { notifier: Arc, ) -> Self { Self { - id: id, - manager: manager, - queue: queue, + id, + manager, + queue, status: Arc::new(Mutex::new(WorkerStatus::Pending)), - shared_handler: shared_handler, - notifier: notifier, + shared_handler, + notifier, } } @@ -153,7 +153,7 @@ impl Manager { status: ManagerStatus::Down, queue: Arc::new(Queue::new()), shared_handler: Arc::new(shared_handler), - notifier: notifier, + notifier, } }