Fix typing in Registry::crate_source

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
Jiahao XU 2025-06-06 13:37:00 +10:00 committed by GitHub
parent ee3af57f4d
commit 6b64129185
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -204,7 +204,7 @@ impl Registry {
pub fn url(&self) -> Result<MaybeOwned<'_, Url>, UrlParseError> {
match self {
#[cfg(feature = "git")]
Registry::Git(registry) => Url::parse(&registry.url().to_string()).map_ok(MaybeOwned::Owned),
Registry::Git(registry) => Url::parse(&registry.url().to_string()).map(MaybeOwned::Owned),
Registry::Sparse(registry) => Ok(MaybeOwned::Borrowed(registry.url())),
}
}
@ -218,14 +218,14 @@ impl Registry {
Registry::Sparse(_) => SourceType::Sparse,
};
match (registry.as_str(), source_type) {
Ok(match (registry.as_str(), source_type) {
("https://index.crates.io/", SourceType::Sparse) |
("https://github.com/rust-lang/crates.io-index", SourceType::Git) => CrateSource::cratesio_registry(),
_ => CrateSource {
source_type,
url: MaybeOwned::Owned(registry.into_owned()),
},
}
})
}
}
@ -233,8 +233,8 @@ impl fmt::Display for Registry {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
#[cfg(feature = "git")]
Registry::Git(registry) => fmt::Display::fmt(&registry.url(), fmt),
Registry::Sparse(registry) => fmt::Display::fmt(&registry.url(), fmt),
Registry::Git(registry) => fmt::Display::fmt(&registry.url(), f),
Registry::Sparse(registry) => fmt::Display::fmt(&registry.url(), f),
}
}
}