Skip to content

Commit

Permalink
Add State::add_version
Browse files Browse the repository at this point in the history
This wrapper avoids accessing `incompatibility_store` directly in uv code.

Before:

```rust
let dep_incompats = self.pubgrub.add_incompatibility_from_dependencies(
    package.clone(),
    version.clone(),
    dependencies,
);
self.pubgrub.partial_solution.add_version(
    package.clone(),
    version.clone(),
    dep_incompats,
    &self.pubgrub.incompatibility_store,
);
```

After:

```rust
self.pubgrub.add_version(package.clone(), version.clone(), dependencies);
```
  • Loading branch information
konstin committed Jun 19, 2024
1 parent a68cbd1 commit f7eb607
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/internal/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ impl<DP: DependencyProvider> State<DP> {
}
}

/// Make a decision for the current package.
pub fn add_version(
&mut self,
package: DP::P,
version: DP::V,
dependencies: impl IntoIterator<Item = (DP::P, DP::VS)>,
) {
let dep_incompats = self.add_incompatibility_from_dependencies(
package.clone(),
version.clone(),
dependencies,
);
self.partial_solution.add_version(
package.clone(),
version.clone(),
dep_incompats,
&self.incompatibility_store,
)
}

/// Add an incompatibility to the state.
pub fn add_incompatibility(&mut self, incompat: Incompatibility<DP::P, DP::VS, DP::M>) {
let id = self.incompatibility_store.alloc(incompat);
Expand Down

0 comments on commit f7eb607

Please sign in to comment.