refact(package.rs): Expose repo field publicly
Expose repo field publicly for install_packages in rustup backend to utilize, otherwise very ugly hacks need to be used to handle toolchains and components. Signed-off-by: innocentzero <isfarulhaque@proton.me>
This commit is contained in:
@@ -6,7 +6,7 @@ use std::hash::Hash;
|
|||||||
#[derive(Debug, Eq, PartialOrd, Ord, Clone)]
|
#[derive(Debug, Eq, PartialOrd, Ord, Clone)]
|
||||||
pub struct Package {
|
pub struct Package {
|
||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
repo: Option<String>,
|
pub(crate) repo: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_comment_and_trim_whitespace(s: &str) -> &str {
|
fn remove_comment_and_trim_whitespace(s: &str) -> &str {
|
||||||
@@ -41,10 +41,11 @@ impl Package {
|
|||||||
///
|
///
|
||||||
/// Panics if `string` is empty.
|
/// Panics if `string` is empty.
|
||||||
fn split_into_name_and_repo(string: &str) -> (String, Option<String>) {
|
fn split_into_name_and_repo(string: &str) -> (String, Option<String>) {
|
||||||
let mut iter = string.split('/').rev();
|
if let Some((before, after)) = string.split_once('/') {
|
||||||
let name = iter.next().expect("we checked that earlier").to_string();
|
(after.to_string(), Some(before.to_string()))
|
||||||
let repo = iter.next().map(|s| s.to_string());
|
} else {
|
||||||
(name, repo)
|
(string.to_string(), None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to parse a string (from a line in a group file) and return a package.
|
/// Try to parse a string (from a line in a group file) and return a package.
|
||||||
|
|||||||
Reference in New Issue
Block a user