1/// Struct, that contains both the original syntax (unprocessed) and the normalized
2/// version. This is useful for code that needs access to both versions of the syntax.
3#[derive(Debug)]
4pub(crate) struct SyntaxVariant<T> {
5/// Original syntax that was passed to the macro without any modifications.
6pub(crate) orig: T,
78/// The value that is equivalent to `orig`, but it underwent normalization.
9pub(crate) norm: T,
10}
1112impl<T> SyntaxVariant<T> {
13pub(crate) fn apply_ref<'a, U>(&'a self, f: impl Fn(&'a T) -> U) -> SyntaxVariant<U> {
14let orig = f(&self.orig);
15let norm = f(&self.norm);
16 SyntaxVariant { orig, norm }
17 }
1819pub(crate) fn into_iter(self) -> impl Iterator<Item = SyntaxVariant<T::Item>>
20where
21T: IntoIterator,
22 {
23self.orig
24 .into_iter()
25 .zip(self.norm)
26 .map(|(orig, norm)| SyntaxVariant { orig, norm })
27 }
28}