Skip to content

Commit 8aa945b

Browse files
committed
Add a method to retrieve unchanging terms for a package (#32)
1 parent bc35e8a commit 8aa945b

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
@@ -589,6 +589,18 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
589589
pub(crate) fn current_decision_level(&self) -> DecisionLevel {
590590
self.current_decision_level
591591
}
592+
593+
/// Retrieve the constraints on a package that will not change.
594+
pub fn unchanging_term_for_package(&self, package: Id<DP::P>) -> Option<&Term<DP::VS>> {
595+
let pa = self.package_assignments.get(&package)?;
596+
597+
let idx_newer = pa
598+
.dated_derivations
599+
.as_slice()
600+
.partition_point(|dd| dd.decision_level <= DecisionLevel(1));
601+
let idx = idx_newer.checked_sub(1)?;
602+
Some(&pa.dated_derivations[idx].accumulated_intersection)
603+
}
592604
}
593605

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

0 commit comments

Comments
 (0)