Skip to content

Commit

Permalink
Support punctuated Pairs iterator in snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 12, 2023
1 parent 06161ba commit 0fcdad0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use proc_macro2::{Ident, Literal, TokenStream};
use ref_cast::RefCast;
use std::fmt::{self, Debug};
use std::ops::Deref;
use syn::punctuated::Punctuated;
use syn::punctuated::{self, Punctuated};

#[derive(RefCast)]
#[repr(transparent)]
Expand Down Expand Up @@ -124,6 +124,22 @@ where
}
}

impl<'a, T, P> Debug for Lite<punctuated::Pairs<'a, T, P>>
where
Lite<T>: Debug,
P: Debug,
{
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let mut list = formatter.debug_list();
for pair in self.value.clone() {
let (node, punct) = pair.into_tuple();
list.entry(Lite(node));
list.entries(punct);
}
list.finish()
}
}

struct Present;

impl Debug for Present {
Expand Down

0 comments on commit 0fcdad0

Please sign in to comment.