Skip to content

Commit 0131488

Browse files
committed
Add a method to retrieve unchanging terms for a package (#32)
1 parent 987e384 commit 0131488

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/internal/partial_solution.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,18 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
586586
pub(crate) fn current_decision_level(&self) -> DecisionLevel {
587587
self.current_decision_level
588588
}
589+
590+
/// Retrieve the constraints on a package that will not change.
591+
pub fn unchanging_term_for_package(&self, package: Id<DP::P>) -> Option<&Term<DP::VS>> {
592+
let pa = self.package_assignments.get(&package)?;
593+
594+
let idx_newer = pa
595+
.dated_derivations
596+
.as_slice()
597+
.partition_point(|dd| dd.decision_level <= DecisionLevel(1));
598+
let idx = idx_newer.checked_sub(1)?;
599+
Some(&pa.dated_derivations[idx].accumulated_intersection)
600+
}
589601
}
590602

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

0 commit comments

Comments
 (0)