From 1b6a04ca5504955c571d1c97504fb45ea0befee4 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 8 Jan 2024 01:21:28 +0400 Subject: Initial vendor packages Signed-off-by: Valentin Popov --- vendor/syn/src/gen_helper.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 vendor/syn/src/gen_helper.rs (limited to 'vendor/syn/src/gen_helper.rs') diff --git a/vendor/syn/src/gen_helper.rs b/vendor/syn/src/gen_helper.rs new file mode 100644 index 0000000..e433bac --- /dev/null +++ b/vendor/syn/src/gen_helper.rs @@ -0,0 +1,34 @@ +#[cfg(feature = "fold")] +pub(crate) mod fold { + use crate::punctuated::{Pair, Punctuated}; + + pub(crate) trait FoldHelper { + type Item; + fn lift(self, f: F) -> Self + where + F: FnMut(Self::Item) -> Self::Item; + } + + impl FoldHelper for Vec { + type Item = T; + fn lift(self, f: F) -> Self + where + F: FnMut(Self::Item) -> Self::Item, + { + self.into_iter().map(f).collect() + } + } + + impl FoldHelper for Punctuated { + type Item = T; + fn lift(self, mut f: F) -> Self + where + F: FnMut(Self::Item) -> Self::Item, + { + self.into_pairs() + .map(Pair::into_tuple) + .map(|(t, u)| Pair::new(f(t), u)) + .collect() + } + } +} -- cgit v1.2.3