Skip to content

Commit

Permalink
refactor: rename packages to potential_packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mpizenberg committed Nov 13, 2020
1 parent 999bc99 commit ee5fdf7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub trait DependencyProvider<P: Package, V: Version> {
/// Note: the type `T` ensures that this returns an item from the `packages` argument.
fn make_decision<T: Borrow<P>, U: Borrow<Range<V>>>(
&self,
packages: impl Iterator<Item = (T, U)>,
potential_packages: impl Iterator<Item = (T, U)>,
) -> Result<(T, Option<V>), Box<dyn Error>>;

/// Retrieves the package dependencies.
Expand Down Expand Up @@ -255,7 +255,7 @@ pub trait DependencyProvider<P: Package, V: Version> {
/// first version contained in the constraints.
pub fn make_fewest_versions_decision_helper<P: Package, V: Version, T, U, I, F>(
list_available_versions: F,
packages: impl Iterator<Item = (T, U)>,
potential_packages: impl Iterator<Item = (T, U)>,
) -> (T, Option<V>)
where
T: Borrow<P>,
Expand All @@ -265,7 +265,7 @@ where
{
let mut package: Option<(T, _)> = None;
let mut min_key = usize::MAX;
for (p, term) in packages {
for (p, term) in potential_packages {
let key = list_available_versions(p.borrow())
.filter(|v| term.borrow().contains(v.borrow()))
.count();
Expand Down Expand Up @@ -348,7 +348,7 @@ impl<P: Package, V: Version> OfflineDependencyProvider<P, V> {
impl<P: Package, V: Version> DependencyProvider<P, V> for OfflineDependencyProvider<P, V> {
fn make_decision<T: Borrow<P>, U: Borrow<Range<V>>>(
&self,
packages: impl Iterator<Item = (T, U)>,
potential_packages: impl Iterator<Item = (T, U)>,
) -> Result<(T, Option<V>), Box<dyn Error>> {
Ok(make_fewest_versions_decision_helper(
|p| {
Expand All @@ -359,7 +359,7 @@ impl<P: Package, V: Version> DependencyProvider<P, V> for OfflineDependencyProvi
.rev()
.cloned()
},
packages,
potential_packages,
))
}

Expand Down
8 changes: 4 additions & 4 deletions tests/proptest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ struct OldestVersionsDependencyProvider<P: Package, V: Version>(OfflineDependenc
impl<P: Package, V: Version> DependencyProvider<P, V> for OldestVersionsDependencyProvider<P, V> {
fn make_decision<T: std::borrow::Borrow<P>, U: std::borrow::Borrow<Range<V>>>(
&self,
packages: impl Iterator<Item = (T, U)>,
potential_packages: impl Iterator<Item = (T, U)>,
) -> Result<(T, Option<V>), Box<dyn Error>> {
Ok(make_fewest_versions_decision_helper(
|p| self.0.versions(p).into_iter().flatten().cloned(),
packages,
potential_packages,
))
}

Expand Down Expand Up @@ -67,9 +67,9 @@ impl<P: Package, V: Version, DP: DependencyProvider<P, V>> DependencyProvider<P,
{
fn make_decision<T: std::borrow::Borrow<P>, U: std::borrow::Borrow<Range<V>>>(
&self,
packages: impl Iterator<Item = (T, U)>,
potential_packages: impl Iterator<Item = (T, U)>,
) -> Result<(T, Option<V>), Box<dyn Error>> {
self.dp.make_decision(packages)
self.dp.make_decision(potential_packages)
}

fn get_dependencies(&self, p: &P, v: &V) -> Result<Dependencies<P, V>, Box<dyn Error>> {
Expand Down

0 comments on commit ee5fdf7

Please sign in to comment.