Skip to content

Commit 25f3377

Browse files
committed
Add a method to retrieve unchanging terms for a package (#32)
1 parent 2975ac2 commit 25f3377

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
@@ -605,6 +605,18 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
605605
pub(crate) fn current_decision_level(&self) -> DecisionLevel {
606606
self.current_decision_level
607607
}
608+
609+
/// Retrieve the constraints on a package that will not change.
610+
pub fn unchanging_term_for_package(&self, package: Id<DP::P>) -> Option<&Term<DP::VS>> {
611+
let pa = self.package_assignments.get(&package)?;
612+
613+
let idx_newer = pa
614+
.dated_derivations
615+
.as_slice()
616+
.partition_point(|dd| dd.decision_level <= DecisionLevel(1));
617+
let idx = idx_newer.checked_sub(1)?;
618+
Some(&pa.dated_derivations[idx].accumulated_intersection)
619+
}
608620
}
609621

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

0 commit comments

Comments
 (0)