cargo clippy fix

This commit is contained in:
rmanach 2023-04-22 15:29:55 +02:00
parent 0f5f8a3ec0
commit b82d968e49
3 changed files with 15 additions and 18 deletions

View File

@ -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<u32> {
match self.body {
Some(ref b) => Some(b.get_id()),
None => None,
}
self.body.as_ref().map(|b| b.get_id())
}
}

View File

@ -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<Message, RunnerError> {
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<Message, RunnerError> {
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())
}

View File

@ -50,12 +50,12 @@ impl<H: Handler, N: Notifier> Worker<H, N> {
notifier: Arc<N>,
) -> 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<H: Handler, N: Notifier> Manager<H, N> {
status: ManagerStatus::Down,
queue: Arc::new(Queue::new()),
shared_handler: Arc::new(shared_handler),
notifier: notifier,
notifier,
}
}