Skip to content

Commit

Permalink
Add a method to retrieve unchanging terms for a package (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Oct 29, 2024
1 parent 0196034 commit 95e1390
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/internal/partial_solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,18 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
pub(crate) fn current_decision_level(&self) -> DecisionLevel {
self.current_decision_level
}

/// Retrieve the constraints on a package that will not change.
pub fn unchanging_term_for_package(&self, package: &DP::P) -> Option<&Term<DP::VS>> {
let pa = self.package_assignments.get(package)?;

let idx_newer = pa
.dated_derivations
.as_slice()
.partition_point(|dd| dd.decision_level <= DecisionLevel(1));
let idx = idx_newer.checked_sub(1)?;
Some(&pa.dated_derivations[idx].accumulated_intersection)
}
}

impl<P: Package, VS: VersionSet, M: Eq + Clone + Debug + Display> PackageAssignments<P, VS, M> {
Expand Down

0 comments on commit 95e1390

Please sign in to comment.