Skip to content

Commit d5fdb12

Browse files
committed
Add a method to retrieve unchanging terms for a package (#32)
1 parent e4284dd commit d5fdb12

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

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

0 commit comments

Comments
 (0)