Skip to content

Commit eef0491

Browse files
committed
Remove choose_package_with_fewest_versions
1 parent 9ebd2d1 commit eef0491

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/limitations/multiple_versions.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ index.add_deps("a", (2, 0, 0), &[("b", (1, 0, 0)..)]);
157157
### Implementing a dependency provider for the index
158158

159159
Since our `Index` is ready, we now have to implement the `DependencyProvider`
160-
trait for it. As explained previously, we'll need to differenciate packages
160+
trait for it. As explained previously, we'll need to differentiate packages
161161
representing buckets and proxies, so we define the following new `Package` type.
162162

163163
```rust
@@ -180,13 +180,15 @@ pub struct Bucket {
180180
}
181181
```
182182

183-
In order to implement the first required method, `choose_package_version`, we
184-
simply reuse the `choose_package_with_fewest_versions` helper function provided
185-
by pubgrub. That one requires a list of available versions for each package, so
186-
we have to create that list. As explained previously, listing the existing
187-
(virtual) versions depend on if the package is a bucket or a proxy. For a bucket
188-
package, we simply need to retrieve the original versions and filter out those
189-
outside of the bucket.
183+
Any `prioritize` will work equally well for this example, even just returning a
184+
constant value.
185+
186+
Let's implement the second function required by a dependency provider,
187+
`choose_version`. For that we defined a `available_versions()` method on an
188+
`Index` to list existing versions of a given package in descending order. As
189+
explained previously, listing the existing (virtual) versions depend on if the
190+
package is a bucket or a proxy. For a bucket package, we simply need to retrieve
191+
the original versions and filter out those outside of the bucket.
190192

191193
```rust
192194
match package {

src/limitations/optional_deps.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ pub enum Package {
125125
}
126126
```
127127

128-
We'll ignore `prioritize` for this example.
128+
Any `prioritize` will work equally well for this example, even just returning a
129+
constant value.
129130

130131
Let's implement the second function required by a dependency provider,
131132
`choose_version`. For that we defined the `base_pkg()` method on a `Package`

src/limitations/public_private.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,12 @@ pub struct Seed {
200200
}
201201
```
202202

203-
Implementing `choose_package_version` is trivial if we simply use the function
204-
`choose_package_with_fewest_versions` provided by pubgrub. Implementing
205-
`get_dependencies` is slightly more complicated. Have a look at the complete
206-
implementation if needed, the main ideas are the following.
203+
Any `prioritize` will work equally well for this example, even just returning a
204+
constant value. Implementing `choose_version` is straightforward enough not to
205+
get additional commentary.
206+
207+
Implementing `get_dependencies` is slightly more complicated. Have a look at the
208+
complete implementation if needed, the main ideas are the following.
207209

208210
```rust
209211
fn get_dependencies(&self, package: &Package, version: &SemVer)

0 commit comments

Comments
 (0)