From ec35c01add12edebeab623e3426a31627e52b16e Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Thu, 7 Nov 2024 01:12:52 -0500 Subject: [PATCH] fix clippy warns --- workspace/gh-workflow/src/toolchain.rs | 6 +- workspace/gh-workflow/src/workflow.rs | 87 +++++++++++++------------- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/workspace/gh-workflow/src/toolchain.rs b/workspace/gh-workflow/src/toolchain.rs index 70530b5..11695ba 100644 --- a/workspace/gh-workflow/src/toolchain.rs +++ b/workspace/gh-workflow/src/toolchain.rs @@ -181,9 +181,9 @@ impl AddStep for ToolchainStep { if let Some(target) = self.target { let target = format!( "{}-{}-{}{}", - target.arch.to_string(), - target.vendor.to_string(), - target.system.to_string(), + target.arch, + target.vendor, + target.system, target.abi.map(|v| v.to_string()).unwrap_or_default(), ); diff --git a/workspace/gh-workflow/src/workflow.rs b/workspace/gh-workflow/src/workflow.rs index 6a09185..09f40c5 100644 --- a/workspace/gh-workflow/src/workflow.rs +++ b/workspace/gh-workflow/src/workflow.rs @@ -1,3 +1,5 @@ +#![allow(clippy::needless_update)] + use std::fmt::Display; use std::path::Path; @@ -133,27 +135,28 @@ impl Workflow { } // TODO: inline this conversion in actual usage -impl Into> for &str { - fn into(self) -> OneOrManyOrObject { - OneOrManyOrObject::Single(self.to_string()) +impl From<&str> for OneOrManyOrObject { + fn from(value: &str) -> Self { + OneOrManyOrObject::Single(value.to_string()) } } // TODO: inline this conversion in actual usage -impl Into> for Vec<&str> { - fn into(self) -> OneOrManyOrObject { - OneOrManyOrObject::Multiple(self.into_iter().map(|s| s.to_string()).collect()) +impl From> for OneOrManyOrObject { + fn from(value: Vec<&str>) -> Self { + OneOrManyOrObject::Multiple(value.iter().map(|s| s.to_string()).collect()) } } // TODO: inline this conversion in actual usage -impl>> Into> for Vec<(&str, V)> { - fn into(self) -> OneOrManyOrObject { - let mut map = IndexMap::new(); - for (key, value) in self { - map.insert(key.to_string(), value.into()); - } - OneOrManyOrObject::KeyValue(map) +impl>> From> for OneOrManyOrObject { + fn from(value: Vec<(&str, V)>) -> Self { + OneOrManyOrObject::KeyValue( + value + .into_iter() + .map(|(s, v)| (s.to_string(), v.into())) + .collect(), + ) } } @@ -419,7 +422,7 @@ impl Step { "{}/{}@v{}", owner.to_string(), repo.to_string(), - version.to_string() + version )), ..Default::default() } @@ -465,41 +468,41 @@ impl SetEnv for (S1, S2) { } } -impl Into> for Step { - fn into(self) -> Step { +impl From> for Step { + fn from(value: Step) -> Self { Step { - id: self.id, - name: self.name, - if_condition: self.if_condition, - uses: self.uses, - with: self.with, - run: self.run, - env: self.env, - timeout_minutes: self.timeout_minutes, - continue_on_error: self.continue_on_error, - working_directory: self.working_directory, - retry: self.retry, - artifacts: self.artifacts, + id: value.id, + name: value.name, + if_condition: value.if_condition, + uses: value.uses, + with: value.with, + run: value.run, + env: value.env, + timeout_minutes: value.timeout_minutes, + continue_on_error: value.continue_on_error, + working_directory: value.working_directory, + retry: value.retry, + artifacts: value.artifacts, marker: Default::default(), } } } -impl Into> for Step { - fn into(self) -> Step { +impl From> for Step { + fn from(value: Step) -> Self { Step { - id: self.id, - name: self.name, - if_condition: self.if_condition, - uses: self.uses, - with: self.with, - run: self.run, - env: self.env, - timeout_minutes: self.timeout_minutes, - continue_on_error: self.continue_on_error, - working_directory: self.working_directory, - retry: self.retry, - artifacts: self.artifacts, + id: value.id, + name: value.name, + if_condition: value.if_condition, + uses: value.uses, + with: value.with, + run: value.run, + env: value.env, + timeout_minutes: value.timeout_minutes, + continue_on_error: value.continue_on_error, + working_directory: value.working_directory, + retry: value.retry, + artifacts: value.artifacts, marker: Default::default(), } }