mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-12 13:28:49 +00:00
Use split_once instead of split().nth(1)
This commit is contained in:
@@ -478,18 +478,14 @@ fn print_packages() -> Result<(), anyhow::Error> {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let empty_table = rows.is_empty();
|
let empty_table = rows.is_empty();
|
||||||
if empty_table {
|
|
||||||
println!("--------------------------------------");
|
|
||||||
println!("Registry Package Version Commands ");
|
|
||||||
println!("======================================");
|
|
||||||
println!();
|
|
||||||
} else {
|
|
||||||
let mut table = Table::init(rows);
|
let mut table = Table::init(rows);
|
||||||
table.set_titles(row!["Registry", "Package", "Version", "Commands"]);
|
table.set_titles(row!["Registry", "Package", "Version", "Commands"]);
|
||||||
table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
|
table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
|
||||||
table.set_format(*format::consts::FORMAT_NO_COLSEP);
|
table.set_format(*format::consts::FORMAT_NO_COLSEP);
|
||||||
let _ = table.printstd();
|
if empty_table {
|
||||||
|
table.add_empty_row();
|
||||||
}
|
}
|
||||||
|
let _ = table.printstd();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -442,14 +442,9 @@ pub fn get_package_local_dir(
|
|||||||
"package name has to be in the format namespace/package: {name:?}"
|
"package name has to be in the format namespace/package: {name:?}"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let namespace = name
|
let (namespace, name) = name
|
||||||
.split('/')
|
.split_once('/')
|
||||||
.next()
|
.ok_or(format!("missing namespace / name for {name:?}"))?;
|
||||||
.ok_or(format!("missing namespace for {name:?}"))?;
|
|
||||||
let name = name
|
|
||||||
.split('/')
|
|
||||||
.nth(1)
|
|
||||||
.ok_or(format!("missing name for {name:?}"))?;
|
|
||||||
let install_dir =
|
let install_dir =
|
||||||
get_global_install_dir(registry_host).ok_or(format!("no install dir for {name:?}"))?;
|
get_global_install_dir(registry_host).ok_or(format!("no install dir for {name:?}"))?;
|
||||||
Ok(install_dir.join(namespace).join(name).join(version))
|
Ok(install_dir.join(namespace).join(name).join(version))
|
||||||
|
|||||||
Reference in New Issue
Block a user