Skip to content

Commit 9eff394

Browse files
committed
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. Signed-off-by: Gary Guo <gary@garyguo.net>
1 parent 393f93d commit 9eff394

1 file changed

Lines changed: 8 additions & 19 deletions

File tree

internal/src/pin_data.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,17 @@ fn generate_projections(
247247
let projection = format_ident!("{ident}Projection");
248248
let this = format_ident!("this");
249249

250-
let (fields_decl, fields_proj) = collect_tuple(fields.iter().map(
251-
|(
252-
pinned,
253-
Field {
250+
let (fields_decl, fields_proj): (Vec<_>, Vec<_>) = fields
251+
.iter()
252+
.map(|(pinned, field)| {
253+
let Field {
254254
vis,
255255
ident,
256256
ty,
257257
attrs,
258258
..
259-
},
260-
)| {
259+
} = field;
260+
261261
let mut no_doc_attrs = attrs.clone();
262262
no_doc_attrs.retain(|a| !a.path().is_ident("doc"));
263263
let ident = ident
@@ -287,8 +287,8 @@ fn generate_projections(
287287
),
288288
)
289289
}
290-
},
291-
));
290+
})
291+
.collect();
292292
let structurally_pinned_fields_docs = fields
293293
.iter()
294294
.filter_map(|(pinned, field)| pinned.then_some(field))
@@ -498,14 +498,3 @@ impl VisitMut for SelfReplacer {
498498
// Do not descend into items, since items reset/change what `Self` refers to.
499499
}
500500
}
501-
502-
// replace with `.collect()` once MSRV is above 1.79
503-
fn collect_tuple<A, B>(iter: impl Iterator<Item = (A, B)>) -> (Vec<A>, Vec<B>) {
504-
let mut res_a = vec![];
505-
let mut res_b = vec![];
506-
for (a, b) in iter {
507-
res_a.push(a);
508-
res_b.push(b);
509-
}
510-
(res_a, res_b)
511-
}

0 commit comments

Comments
 (0)