Skip to content

Commit ea28e95

Browse files
authored
Merge partial solution impl blocks (#292)
There were two identical impl block for `impl<DP: DependencyProvider> PartialSolution<DP>`, so I merged them. I've also reduced the visibility since `PartialSolution` is also `pub(crate)`.
1 parent 3741e3b commit ea28e95

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

src/internal/partial_solution.rs

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,33 +51,6 @@ pub(crate) struct PartialSolution<DP: DependencyProvider> {
5151
has_ever_backtracked: bool,
5252
}
5353

54-
impl<DP: DependencyProvider> PartialSolution<DP> {
55-
pub fn display<'a>(&'a self, package_store: &'a HashArena<DP::P>) -> impl Display + 'a {
56-
struct PSDisplay<'a, DP: DependencyProvider>(&'a PartialSolution<DP>, &'a HashArena<DP::P>);
57-
58-
impl<DP: DependencyProvider> Display for PSDisplay<'_, DP> {
59-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
60-
let mut assignments: Vec<_> = self
61-
.0
62-
.package_assignments
63-
.iter()
64-
.map(|(p, pa)| format!("{:?} = '{}': {}", p, self.1[*p], pa))
65-
.collect();
66-
assignments.sort();
67-
write!(
68-
f,
69-
"next_global_index: {}\ncurrent_decision_level: {:?}\npackage_assignments:\n{}",
70-
self.0.next_global_index,
71-
self.0.current_decision_level,
72-
assignments.join("\t\n")
73-
)
74-
}
75-
}
76-
77-
PSDisplay(self, package_store)
78-
}
79-
}
80-
8154
/// Package assignments contain the potential decision and derivations
8255
/// that have already been made for a given package,
8356
/// as well as the intersection of terms by all of these.
@@ -167,6 +140,31 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
167140
}
168141
}
169142

143+
pub(crate) fn display<'a>(&'a self, package_store: &'a HashArena<DP::P>) -> impl Display + 'a {
144+
struct PSDisplay<'a, DP: DependencyProvider>(&'a PartialSolution<DP>, &'a HashArena<DP::P>);
145+
146+
impl<DP: DependencyProvider> Display for PSDisplay<'_, DP> {
147+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
148+
let mut assignments: Vec<_> = self
149+
.0
150+
.package_assignments
151+
.iter()
152+
.map(|(p, pa)| format!("{:?} = '{}': {}", p, self.1[*p], pa))
153+
.collect();
154+
assignments.sort();
155+
write!(
156+
f,
157+
"next_global_index: {}\ncurrent_decision_level: {:?}\npackage_assignments:\n{}",
158+
self.0.next_global_index,
159+
self.0.current_decision_level,
160+
assignments.join("\t\n")
161+
)
162+
}
163+
}
164+
165+
PSDisplay(self, package_store)
166+
}
167+
170168
/// Add a decision.
171169
pub(crate) fn add_decision(&mut self, package: Id<DP::P>, version: DP::V) {
172170
// Check that add_decision is never used in the wrong context.

0 commit comments

Comments
 (0)