Refactor: Simplify struct Resolution

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-19 00:43:17 +10:00
parent c6281d8ea0
commit b026462018
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -335,7 +335,7 @@ enum Resolution {
Fetch { Fetch {
fetcher: Arc<dyn Fetcher>, fetcher: Arc<dyn Fetcher>,
package: Package<Meta>, package: Package<Meta>,
crate_name: CrateName, name: String,
version: String, version: String,
bin_path: PathBuf, bin_path: PathBuf,
bin_files: Vec<bins::BinFile>, bin_files: Vec<bins::BinFile>,
@ -487,7 +487,7 @@ async fn resolve(
Resolution::Fetch { Resolution::Fetch {
fetcher, fetcher,
package, package,
crate_name, name: crate_name.name,
version, version,
bin_path, bin_path,
bin_files, bin_files,
@ -555,13 +555,13 @@ async fn install(
Resolution::Fetch { Resolution::Fetch {
fetcher, fetcher,
package, package,
crate_name, name,
version, version,
bin_path, bin_path,
bin_files, bin_files,
} => { } => {
install_from_package( install_from_package(
fetcher, opts, package, crate_name, temp_dir, version, bin_path, bin_files, fetcher, opts, package, name, temp_dir, version, bin_path, bin_files,
) )
.await .await
} }
@ -584,7 +584,7 @@ async fn install_from_package(
fetcher: Arc<dyn Fetcher>, fetcher: Arc<dyn Fetcher>,
opts: Arc<Options>, opts: Arc<Options>,
package: Package<Meta>, package: Package<Meta>,
crate_name: CrateName, name: String,
temp_dir: Arc<Path>, temp_dir: Arc<Path>,
version: String, version: String,
bin_path: PathBuf, bin_path: PathBuf,
@ -627,7 +627,7 @@ async fn install_from_package(
} }
let cvs = metafiles::CrateVersionSource { let cvs = metafiles::CrateVersionSource {
name: crate_name.name.clone(), name: name.clone(),
version: package.version.parse().into_diagnostic()?, version: package.version.parse().into_diagnostic()?,
source: metafiles::Source::Registry( source: metafiles::Source::Registry(
url::Url::parse("https://github.com/rust-lang/crates.io-index").unwrap(), url::Url::parse("https://github.com/rust-lang/crates.io-index").unwrap(),