Skip to content

Commit 9cd9049

Browse files
konstincharliermarsh
authored andcommitted
Add a method to retrieve unchanging terms for a package (#32)
1 parent 0ffb99f commit 9cd9049

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
@@ -529,6 +529,18 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
529529
pub(crate) fn current_decision_level(&self) -> DecisionLevel {
530530
self.current_decision_level
531531
}
532+
533+
/// Retrieve the constraints on a package that will not change.
534+
pub fn unchanging_term_for_package(&self, package: Id<DP::P>) -> Option<&Term<DP::VS>> {
535+
let pa = self.package_assignments.get(&package)?;
536+
537+
let idx_newer = pa
538+
.dated_derivations
539+
.as_slice()
540+
.partition_point(|dd| dd.decision_level <= DecisionLevel(1));
541+
let idx = idx_newer.checked_sub(1)?;
542+
Some(&pa.dated_derivations[idx].accumulated_intersection)
543+
}
532544
}
533545

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

0 commit comments

Comments
 (0)