Skip to content

Commit

Permalink
apply clippy suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
boozook and github-actions[bot] authored Jun 9, 2024
1 parent 857fd02 commit aad4615
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
8 changes: 4 additions & 4 deletions cargo/src/assets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ pub mod proto {
.flat_map(|(key, index)| {
self.tree
.roots()
.into_iter()
.iter()
.filter(|r| key.is_for(r))
.map(|root| (root, index.as_slice()))
})
.map(|(root, index)| {
let arts = index.into_iter().map(|i| &self.artifacts[*i]);
let arts = index.iter().map(|i| &self.artifacts[*i]);
(root, arts)
})
}
Expand Down Expand Up @@ -266,7 +266,7 @@ pub mod proto {
let msg = format!("{kind_prefix}assets pre-build for {}, {REASON}.", key.id);
cfg.log().status("Skip", msg);
} else {
let kind = key.dev.then_some(AssetKind::Dev).unwrap_or(AssetKind::Package);
let kind = if key.dev { AssetKind::Dev } else { AssetKind::Package };
match pdc::build(cfg, &key.id, locked.as_inner(), kind) {
Ok(_) => {
let msg = format!("{kind_prefix}assets for {}", key.id);
Expand All @@ -289,7 +289,7 @@ pub mod proto {
locked.unlock();


let kind = key.dev.then_some(AssetKind::Dev).unwrap_or(AssetKind::Package);
let kind = if key.dev { AssetKind::Dev } else { AssetKind::Package };
let art_index = artifacts.artifacts.len();
artifacts.artifacts.push(AssetsArtifact { kind,
package_id: key.id,
Expand Down
21 changes: 10 additions & 11 deletions cargo/src/assets/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub mod proto {
use playdate::assets::plan::BuildPlan;
use playdate::consts::SDK_ENV_VAR;
use playdate::manifest::PackageSource as _;
use playdate::metadata::format::{AssetsOptions, Options};
use playdate::metadata::format::AssetsOptions;
use playdate::metadata::source::MetadataSource as _;

use crate::utils::cargo::meta_deps::MetaDeps;
Expand Down Expand Up @@ -127,7 +127,7 @@ pub mod proto {
fn from(root: &'_ RootNode<'_>) -> Self {
Self { dev: root.node().target().is_dev(),
id: root.deps()
.into_iter()
.iter()
.map(|d| d.package_id().to_owned())
.collect() }
}
Expand All @@ -138,7 +138,7 @@ pub mod proto {
pub fn is_for(&self, root: &'_ RootNode<'_>) -> bool {
root.node().target().is_dev() == self.dev &&
root.deps()
.into_iter()
.iter()
.enumerate()
.all(|(i, d)| self.id.get(i).filter(|k| *k == d.package_id()).is_some())
// root.deps().into_iter().enumerate().all(|(i, d)| d.package_id() == &self.id[i])
Expand All @@ -154,13 +154,12 @@ pub mod proto {

// prepare env:
let global_env: BTreeMap<_, _> =
std::env::vars().into_iter()
.map(|(k, v)| (k, v))
std::env::vars()
.chain({
cfg.sdk()
.map(|sdk| sdk.path())
.ok()
.or_else(|| cfg.sdk_path.as_deref())
.or(cfg.sdk_path.as_deref())
.map(|p| (SDK_ENV_VAR.to_string(), p.display().to_string()))
.into_iter()
})
Expand All @@ -175,7 +174,7 @@ pub mod proto {

let iter = global_env.iter()
.map(|(k, v)| (Cow::Borrowed(k.as_str()), Cow::Borrowed(v.as_str())))
.chain(vars.into_iter());
.chain(vars);

Env::try_from_iter(iter).map_err(|err| anyhow::anyhow!("{err}"))
};
Expand Down Expand Up @@ -230,7 +229,7 @@ pub mod proto {
// let plan =
match assets_build_plan(&env, assets, &options, Some(crate_root.into())) {
Ok(plan) => {
let pid = key.id.clone();
let pid = key.id;
let is_dev = key.dev;
let dev_index = plans.plans.len();
plans.index.insert(key, dev_index);
Expand Down Expand Up @@ -334,7 +333,7 @@ pub mod proto {
.iter()
.flat_map(|(key, _)| {
tree.roots()
.into_iter()
.iter()
.filter(|r| key.is_for(r))
.map(move |r| (key, r))
})
Expand Down Expand Up @@ -397,7 +396,7 @@ pub mod proto {
if let Some(past) = targets.get(&target) &&
past.len() > 1
{
let id = past.into_iter()
let id = past.iter()
.flat_map(|x| plans.index.iter().find_map(|(key, i)| (i == x).then_some(key)))
.collect::<Vec<_>>();
debug_assert!(!id.is_empty());
Expand All @@ -410,7 +409,7 @@ pub mod proto {
.then_some("by itself")
.map(Cow::from)
.unwrap_or_else(|| {
other.into_iter()
other.iter()
.map(|k| {
let dev = k.dev.then_some("dev-").unwrap_or_default();
format!("{}'s '{dev}assets'", k.id.name())
Expand Down
2 changes: 1 addition & 1 deletion cargo/src/utils/cargo/meta_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub struct Node<'cfg> {
impl<'t> Node<'t> {
pub fn package_id(&self) -> &'t PackageId { &self.unit.package_id }

pub fn unit(&self) -> &'t Unit { &self.unit }
pub fn unit(&self) -> &'t Unit { self.unit }
pub fn meta(&self) -> Option<&'t Package<CrateMetadata<InternedString>>> { self.meta }
pub fn target(&self) -> &'t UnitTarget { &self.unit.target }

Expand Down

0 comments on commit aad4615

Please sign in to comment.