aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
authorGary Guo <gary@garyguo.net>2026-05-01 14:44:45 +0100
committerGary Guo <gary@garyguo.net>2026-05-10 22:58:34 +0100
commitfaed81945d0bfcced81a2738d9681a265d41079a (patch)
treef7918299ac29ec5d3f6237a3f4fc46999be7170d /rust
parente5cece935531997cd9903c129cc9a2471ed05a4b (diff)
downloadlinux-next-history-faed81945d0bfcced81a2738d9681a265d41079a.tar.gz
rust: pin-init: internal: remove `collect_tuple` polyfill after MSRV bump
Tuples implement `FromIterator` since Rust 1.79. Remove the `collect_tuple` polyfill now the MSRV is above 1.79. To avoid over-identing the closure, I move the `Field` destructure from the closure parameter to a let binding. This keeps the diff small. Link: https://patch.msgid.link/20260501134445.3809731-1-gary@garyguo.net Signed-off-by: Gary Guo <gary@garyguo.net>
Diffstat (limited to 'rust')
-rw-r--r--rust/pin-init/internal/src/pin_data.rs27
1 files changed, 8 insertions, 19 deletions
diff --git a/rust/pin-init/internal/src/pin_data.rs b/rust/pin-init/internal/src/pin_data.rs
index 163a31ed1556e..be3d97a382257 100644
--- a/rust/pin-init/internal/src/pin_data.rs
+++ b/rust/pin-init/internal/src/pin_data.rs
@@ -247,17 +247,17 @@ fn generate_projections(
let projection = format_ident!("{ident}Projection");
let this = format_ident!("this");
- let (fields_decl, fields_proj) = collect_tuple(fields.iter().map(
- |(
- pinned,
- Field {
+ let (fields_decl, fields_proj): (Vec<_>, Vec<_>) = fields
+ .iter()
+ .map(|(pinned, field)| {
+ let Field {
vis,
ident,
ty,
attrs,
..
- },
- )| {
+ } = field;
+
let mut no_doc_attrs = attrs.clone();
no_doc_attrs.retain(|a| !a.path().is_ident("doc"));
let ident = ident
@@ -287,8 +287,8 @@ fn generate_projections(
),
)
}
- },
- ));
+ })
+ .collect();
let structurally_pinned_fields_docs = fields
.iter()
.filter_map(|(pinned, field)| pinned.then_some(field))
@@ -498,14 +498,3 @@ impl VisitMut for SelfReplacer {
// Do not descend into items, since items reset/change what `Self` refers to.
}
}
-
-// replace with `.collect()` once MSRV is above 1.79
-fn collect_tuple<A, B>(iter: impl Iterator<Item = (A, B)>) -> (Vec<A>, Vec<B>) {
- let mut res_a = vec![];
- let mut res_b = vec![];
- for (a, b) in iter {
- res_a.push(a);
- res_b.push(b);
- }
- (res_a, res_b)
-}