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 authored and charliermarsh committed Nov 26, 2024
1 parent 0ffb99f commit 9cd9049
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 @@ -529,6 +529,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: Id<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 9cd9049

Please sign in to comment.