Skip to content

Commit

Permalink
Use IndexUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Apr 10, 2024
1 parent 2c50f89 commit 6c03a88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions crates/distribution-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl Dist {
}
}

pub fn index(&self) -> Option<String> {
pub fn index(&self) -> Option<&IndexUrl> {
match self {
Self::Built(dist) => dist.index(),
Self::Source(dist) => dist.index(),
Expand All @@ -395,9 +395,9 @@ impl Dist {
}

impl BuiltDist {
pub fn index(&self) -> Option<String> {
pub fn index(&self) -> Option<&IndexUrl> {
match self {
Self::Registry(registry) => Some(registry.index.to_string()),
Self::Registry(registry) => Some(&registry.index),
Self::DirectUrl(_) => None,
Self::Path(_) => None,
}
Expand All @@ -421,9 +421,9 @@ impl BuiltDist {
}

impl SourceDist {
pub fn index(&self) -> Option<String> {
pub fn index(&self) -> Option<&IndexUrl> {
match self {
Self::Registry(registry) => Some(registry.index.to_string()),
Self::Registry(registry) => Some(&registry.index),
Self::DirectUrl(_) | Self::Git(_) | Self::Path(_) => None,
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/distribution-types/src/resolved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::fmt::{Display, Formatter};
use pep508_rs::PackageName;

use crate::{
Dist, DistributionId, DistributionMetadata, Identifier, InstalledDist, Name, ResourceId,
VersionOrUrl,
Dist, DistributionId, DistributionMetadata, Identifier, IndexUrl, InstalledDist, Name,
ResourceId, VersionOrUrl,
};

/// A distribution that can be used for resolution and installation.
Expand Down Expand Up @@ -32,7 +32,7 @@ impl ResolvedDist {
}
}

pub fn index(&self) -> Option<String> {
pub fn index(&self) -> Option<&IndexUrl> {
match self {
Self::Installable(dist) => dist.index(),
Self::Installed(_) => None,
Expand Down
5 changes: 3 additions & 2 deletions crates/uv-resolver/src/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use pubgrub::type_aliases::SelectedDependencies;
use rustc_hash::{FxHashMap, FxHashSet};

use distribution_types::{
Dist, DistributionMetadata, LocalEditable, Name, PackageId, ResolvedDist, Verbatim,
Dist, DistributionMetadata, IndexUrl, LocalEditable, Name, PackageId, ResolvedDist, Verbatim,
VersionOrUrl,
};
use once_map::OnceMap;
Expand Down Expand Up @@ -584,7 +584,8 @@ impl<'a> Node<'a> {
}
}

fn index(&self) -> Option<String> {
/// Return the [`IndexUrl`] of the distribution, if any.
fn index(&self) -> Option<&IndexUrl> {
match self {
Node::Editable(_, _) => None,
Node::Distribution(_, dist, _) => dist.index(),
Expand Down

0 comments on commit 6c03a88

Please sign in to comment.