bon_macros/normalization/
syntax_variant.rs1#[derive(Debug)]
4pub(crate) struct SyntaxVariant<T> {
5 pub(crate) orig: T,
7
8 pub(crate) norm: T,
10}
11
12impl<T> SyntaxVariant<T> {
13 pub(crate) fn apply_ref<'a, U>(&'a self, f: impl Fn(&'a T) -> U) -> SyntaxVariant<U> {
14 let orig = f(&self.orig);
15 let norm = f(&self.norm);
16 SyntaxVariant { orig, norm }
17 }
18
19 pub(crate) fn into_iter(self) -> impl Iterator<Item = SyntaxVariant<T::Item>>
20 where
21 T: IntoIterator,
22 {
23 self.orig
24 .into_iter()
25 .zip(self.norm)
26 .map(|(orig, norm)| SyntaxVariant { orig, norm })
27 }
28}