summaryrefslogtreecommitdiffstats
path: root/rust/vendor/syn/src/gen_helper.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:39:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:39:49 +0000
commita0aa2307322cd47bbf416810ac0292925e03be87 (patch)
tree37076262a026c4b48c8a0e84f44ff9187556ca35 /rust/vendor/syn/src/gen_helper.rs
parentInitial commit. (diff)
downloadsuricata-a0aa2307322cd47bbf416810ac0292925e03be87.tar.xz
suricata-a0aa2307322cd47bbf416810ac0292925e03be87.zip
Adding upstream version 1:7.0.3.upstream/1%7.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'rust/vendor/syn/src/gen_helper.rs')
-rw-r--r--rust/vendor/syn/src/gen_helper.rs34
1 files changed, 34 insertions, 0 deletions
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<F>(self, f: F) -> Self
+ where
+ F: FnMut(Self::Item) -> Self::Item;
+ }
+
+ impl<T> FoldHelper for Vec<T> {
+ type Item = T;
+ fn lift<F>(self, f: F) -> Self
+ where
+ F: FnMut(Self::Item) -> Self::Item,
+ {
+ self.into_iter().map(f).collect()
+ }
+ }
+
+ impl<T, U> FoldHelper for Punctuated<T, U> {
+ type Item = T;
+ fn lift<F>(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()
+ }
+ }
+}