mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Remove unused methods from Resolution
(#3754)
This commit is contained in:
parent
0a87391d5d
commit
fe28b2c278
7 changed files with 11 additions and 24 deletions
|
@ -30,7 +30,6 @@ indexmap = { workspace = true }
|
|||
itertools = { workspace = true }
|
||||
once_cell = { workspace = true }
|
||||
rkyv = { workspace = true }
|
||||
rustc-hash = { workspace = true }
|
||||
schemars = { workspace = true, optional = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_hash::FxHashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use pep508_rs::VerbatimUrl;
|
||||
use uv_normalize::PackageName;
|
||||
|
@ -10,19 +10,14 @@ use crate::{
|
|||
|
||||
/// A set of packages pinned at specific versions.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Resolution(FxHashMap<PackageName, ResolvedDist>);
|
||||
pub struct Resolution(BTreeMap<PackageName, ResolvedDist>);
|
||||
|
||||
impl Resolution {
|
||||
/// Create a new resolution from the given pinned packages.
|
||||
pub fn new(packages: FxHashMap<PackageName, ResolvedDist>) -> Self {
|
||||
pub fn new(packages: BTreeMap<PackageName, ResolvedDist>) -> Self {
|
||||
Self(packages)
|
||||
}
|
||||
|
||||
/// Return the distribution for the given package name, if it exists.
|
||||
pub fn get(&self, package_name: &PackageName) -> Option<&ResolvedDist> {
|
||||
self.0.get(package_name)
|
||||
}
|
||||
|
||||
/// Return the remote distribution for the given package name, if it exists.
|
||||
pub fn get_remote(&self, package_name: &PackageName) -> Option<&Dist> {
|
||||
match self.0.get(package_name) {
|
||||
|
@ -44,11 +39,6 @@ impl Resolution {
|
|||
self.0.values()
|
||||
}
|
||||
|
||||
/// Iterate over the [`ResolvedDist`] entities in this resolution.
|
||||
pub fn into_distributions(self) -> impl Iterator<Item = ResolvedDist> {
|
||||
self.0.into_values()
|
||||
}
|
||||
|
||||
/// Return the number of distributions in this resolution.
|
||||
pub fn len(&self) -> usize {
|
||||
self.0.len()
|
||||
|
@ -60,10 +50,8 @@ impl Resolution {
|
|||
}
|
||||
|
||||
/// Return the set of [`Requirement`]s that this resolution represents.
|
||||
pub fn requirements(&self) -> Vec<Requirement> {
|
||||
let mut requirements: Vec<_> = self.0.values().map(Requirement::from).collect();
|
||||
requirements.sort_unstable_by(|a, b| a.name.cmp(&b.name));
|
||||
requirements
|
||||
pub fn requirements(&self) -> impl Iterator<Item = Requirement> + '_ {
|
||||
self.0.values().map(Requirement::from)
|
||||
}
|
||||
|
||||
/// Return an iterator over the [`LocalEditable`] entities in this resolution.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue