From a0aa2307322cd47bbf416810ac0292925e03be87 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 19:39:49 +0200 Subject: Adding upstream version 1:7.0.3. Signed-off-by: Daniel Baumann --- rust/vendor/syn/src/gen_helper.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 rust/vendor/syn/src/gen_helper.rs (limited to 'rust/vendor/syn/src/gen_helper.rs') diff --git a/rust/vendor/syn/src/gen_helper.rs b/rust/vendor/syn/src/gen_helper.rs new file mode 100644 index 0000000..e433bac --- /dev/null +++ b/rust/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