Skip to content

Commit 72df372

Browse files
committed
add Debug to search::Outcome
1 parent 2b48686 commit 72df372

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

gix-attributes/src/search/outcome.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,29 @@ impl Outcome {
223223
}
224224
}
225225

226+
impl std::fmt::Debug for Outcome {
227+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
228+
struct AsDisplay<'a>(&'a dyn std::fmt::Display);
229+
impl std::fmt::Debug for AsDisplay<'_> {
230+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
231+
self.0.fmt(f)
232+
}
233+
}
234+
235+
let mut dbg = f.debug_tuple("Outcome");
236+
if self.selected.is_empty() {
237+
for match_ in self.iter() {
238+
dbg.field(&AsDisplay(&match_.assignment));
239+
}
240+
} else {
241+
for match_ in self.iter_selected() {
242+
dbg.field(&AsDisplay(&match_.assignment));
243+
}
244+
}
245+
dbg.finish()
246+
}
247+
}
248+
226249
/// Mutation
227250
impl MetadataCollection {
228251
/// Assign order ids to each attribute either in macros (along with macros themselves) or attributes of patterns, and store

0 commit comments

Comments
 (0)