Skip to content

Commit d4977d1

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

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
@@ -521,6 +521,18 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
521521
pub(crate) fn current_decision_level(&self) -> DecisionLevel {
522522
self.current_decision_level
523523
}
524+
525+
/// Retrieve the constraints on a package that will not change.
526+
pub fn unchanging_term_for_package(&self, package: &DP::P) -> Option<&Term<DP::VS>> {
527+
let pa = self.package_assignments.get(package)?;
528+
529+
let idx_newer = pa
530+
.dated_derivations
531+
.as_slice()
532+
.partition_point(|dd| dd.decision_level <= DecisionLevel(1));
533+
let idx = idx_newer.checked_sub(1)?;
534+
Some(&pa.dated_derivations[idx].accumulated_intersection)
535+
}
524536
}
525537

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

0 commit comments

Comments
 (0)