Skip to content

Commit

Permalink
refactor: rename helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksator authored and Eh2406 committed Nov 15, 2020
1 parent f18b9bf commit aafb1d7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
//!
//! The first method [make_decision](crate::solver::DependencyProvider::make_decision) chooses a
//! package and available version compatible with the provided options.
//! A helper function [make_fewest_versions_decision_helper](crate::solver::make_fewest_versions_decision_helper)
//! A helper function
//! [choose_package_with_fewest_versions](crate::solver::choose_package_with_fewest_versions)
//! is provided for convenience
//! in cases when lists of available versions for packages are easily obtained.
//! The strategy of that helper function consists in choosing the package
Expand Down
6 changes: 3 additions & 3 deletions src/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub trait DependencyProvider<P: Package, V: Version> {
/// > since these packages will run out of versions to try more quickly.
/// > But there's likely room for improvement in these heuristics.
///
/// A helper function [make_fewest_versions_decision_helper] is provided to ease
/// A helper function [choose_package_with_fewest_versions] is provided to ease
/// implementations of this method if you can produce an iterator
/// of the available versions in preference order for any package.
///
Expand Down Expand Up @@ -268,7 +268,7 @@ pub trait DependencyProvider<P: Package, V: Version> {
/// The helper finds the package from the `packages` argument with the fewest versions from
/// `list_available_versions` contained in the constraints. Then takes that package and finds the
/// first version contained in the constraints.
pub fn make_fewest_versions_decision_helper<P: Package, V: Version, T, U, I, F>(
pub fn choose_package_with_fewest_versions<P: Package, V: Version, T, U, I, F>(
list_available_versions: F,
potential_packages: impl Iterator<Item = (T, U)>,
) -> (T, Option<V>)
Expand Down Expand Up @@ -360,7 +360,7 @@ impl<P: Package, V: Version> DependencyProvider<P, V> for OfflineDependencyProvi
&self,
potential_packages: impl Iterator<Item = (T, U)>,
) -> Result<(T, Option<V>), Box<dyn Error>> {
Ok(make_fewest_versions_decision_helper(
Ok(choose_package_with_fewest_versions(
|p| {
self.dependencies
.get(p)
Expand Down
4 changes: 2 additions & 2 deletions tests/proptest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pubgrub::package::Package;
use pubgrub::range::Range;
use pubgrub::report::{DefaultStringReporter, Reporter};
use pubgrub::solver::{
make_fewest_versions_decision_helper, resolve, Dependencies, DependencyProvider,
choose_package_with_fewest_versions, resolve, Dependencies, DependencyProvider,
OfflineDependencyProvider,
};
use pubgrub::version::{NumberVersion, Version};
Expand All @@ -31,7 +31,7 @@ impl<P: Package, V: Version> DependencyProvider<P, V> for OldestVersionsDependen
&self,
potential_packages: impl Iterator<Item = (T, U)>,
) -> Result<(T, Option<V>), Box<dyn Error>> {
Ok(make_fewest_versions_decision_helper(
Ok(choose_package_with_fewest_versions(
|p| self.0.versions(p).into_iter().flatten().cloned(),
potential_packages,
))
Expand Down

0 comments on commit aafb1d7

Please sign in to comment.