From a5325ac1a9b565ee7dc2a87976a54d97307c67a6 Mon Sep 17 00:00:00 2001 From: Jan Likar Date: Mon, 26 Aug 2024 00:03:59 +0200 Subject: [PATCH] Code formatting --- cargo-clone-core/src/cloner_builder.rs | 2 +- cargo-clone-core/src/lib.rs | 28 +++++++++++++++++--------- cargo-clone-core/src/source.rs | 2 +- cargo-clone/src/main.rs | 4 +++- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/cargo-clone-core/src/cloner_builder.rs b/cargo-clone-core/src/cloner_builder.rs index bea595a..9276318 100644 --- a/cargo-clone-core/src/cloner_builder.rs +++ b/cargo-clone-core/src/cloner_builder.rs @@ -9,8 +9,8 @@ use std::{env, path::PathBuf}; use anyhow::Context; -use cargo::CargoResult; use cargo::util::context::GlobalContext; +use cargo::CargoResult; use crate::{Cloner, ClonerSource}; diff --git a/cargo-clone-core/src/lib.rs b/cargo-clone-core/src/lib.rs index 190e989..9c344b5 100644 --- a/cargo-clone-core/src/lib.rs +++ b/cargo-clone-core/src/lib.rs @@ -25,10 +25,10 @@ use anyhow::{bail, Context}; use cargo::core::dependency::Dependency; use cargo::core::Package; +use cargo::sources::registry::IndexSummary; use cargo::sources::source::QueryKind; use cargo::sources::source::Source; use cargo::sources::{PathSource, SourceConfigMap}; -use cargo::sources::registry::IndexSummary; use cargo::util::cache_lock::CacheLockMode; use cargo::util::context::GlobalContext; use semver::VersionReq; @@ -36,10 +36,7 @@ use semver::VersionReq; use walkdir::WalkDir; // Re-export cargo types. -pub use cargo::{ - core::SourceId, - util::CargoResult, -}; +pub use cargo::{core::SourceId, util::CargoResult}; /// Rust crate. #[derive(PartialEq, Eq, Debug)] @@ -80,7 +77,9 @@ impl Cloner { /// Clone the specified crate from registry or git repository. /// The crate is cloned in the directory specified by the [`ClonerBuilder`]. pub fn clone_in_dir(&self, crate_: &Crate) -> CargoResult<()> { - let _lock = self.context.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?; + let _lock = self + .context + .acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?; let mut src = get_source(&self.srcid, &self.context)?; @@ -90,7 +89,9 @@ impl Cloner { /// Clone the specified crates from registry or git repository. /// Each crate is cloned in a subdirectory named as the crate name. pub fn clone(&self, crates: &[Crate]) -> CargoResult<()> { - let _lock = self.context.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?; + let _lock = self + .context + .acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?; let mut src = get_source(&self.srcid, &self.context)?; @@ -154,7 +155,10 @@ impl Cloner { } } -fn get_source<'a>(srcid: &SourceId, context: &'a GlobalContext) -> CargoResult> { +fn get_source<'a>( + srcid: &SourceId, + context: &'a GlobalContext, +) -> CargoResult> { let mut source = if srcid.is_path() { let path = srcid.url().to_file_path().expect("path must be valid"); Box::new(PathSource::new(&path, *srcid, context)) @@ -188,8 +192,12 @@ where } } - let latest = summaries.iter() - .filter_map(|idxs| match idxs { IndexSummary::Candidate(s) => Some(s), _ => None}) + let latest = summaries + .iter() + .filter_map(|idxs| match idxs { + IndexSummary::Candidate(s) => Some(s), + _ => None, + }) .max_by_key(|s| s.version()); match latest { diff --git a/cargo-clone-core/src/source.rs b/cargo-clone-core/src/source.rs index b0927cf..501ae35 100644 --- a/cargo-clone-core/src/source.rs +++ b/cargo-clone-core/src/source.rs @@ -6,8 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cargo::{core::SourceId, util::IntoUrl, CargoResult}; use cargo::util::GlobalContext; +use cargo::{core::SourceId, util::IntoUrl, CargoResult}; use url::Url; /// Where to clone the crate from. diff --git a/cargo-clone/src/main.rs b/cargo-clone/src/main.rs index 3526a6e..4aa82f5 100644 --- a/cargo-clone/src/main.rs +++ b/cargo-clone/src/main.rs @@ -70,7 +70,9 @@ pub fn execute(opts: &CloneOpt) -> Result<()> { .collect::>>()?; let context = cargo_context(opts)?; - let mut cloner_builder = ClonerBuilder::new().with_source(source).with_context(context); + let mut cloner_builder = ClonerBuilder::new() + .with_source(source) + .with_context(context); let directory = opts.directory.as_deref(); if let Some(directory) = directory { cloner_builder = cloner_builder.with_directory(directory);