diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-09-29 21:06:45 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-29 21:06:45 +1000 |
| commit | 08616a17457bb93eb177d9189f92345d1924294d (patch) | |
| tree | 63c971995ccb1993d59c0c8f27d310c8fee0a08a /src | |
| parent | acd91e2fe1abc802a41cef4496a375bde7053394 (diff) | |
| parent | 68a7c250788833305f73f816b284aafa9e62370a (diff) | |
| download | rust-08616a17457bb93eb177d9189f92345d1924294d.tar.gz rust-08616a17457bb93eb177d9189f92345d1924294d.zip | |
Rollup merge of #147101 - yotamofek:pr/iter-eq-and-eq-by, r=jdonszelmann
Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library Now that rust-lang/rust#137122 has landed, we can replace stuff that looks like: ```rust let a: &[T]; let b: &[T]; let eq = a.len() == b.len() && a.iter().zip(b).all(|(a,b)| a == b) ``` with the much simpler `a.iter().eq(b)`, without losing the perf benefit of the different-length-fast-path. Also dogfooded `Iterator::eq_by` (cc rust-lang/rust#64295 ) while I'm at it. First commit (4d1b6fad230f8a5ccceccc7562eadc4ea50059da) should be very straightforward to review, second one (049a4606cb3906787aedf508ee8eea09c2bb3b9a) is slightly more creative, but IMHO a nice cleanup.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/lib.rs | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index c2cf39c4be0..4eb32585ffb 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1685,7 +1685,7 @@ impl Type { match (self_cleared, other_cleared) { // Recursive cases. (Type::Tuple(a), Type::Tuple(b)) => { - a.len() == b.len() && a.iter().zip(b).all(|(a, b)| a.is_doc_subtype_of(b, cache)) + a.iter().eq_by(b, |a, b| a.is_doc_subtype_of(b, cache)) } (Type::Slice(a), Type::Slice(b)) => a.is_doc_subtype_of(b, cache), (Type::Array(a, al), Type::Array(b, bl)) => al == bl && a.is_doc_subtype_of(b, cache), diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index c4f24e09ddb..d7ffb25f8bd 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -13,6 +13,7 @@ #![feature(if_let_guard)] #![feature(iter_advance_by)] #![feature(iter_intersperse)] +#![feature(iter_order_by)] #![feature(rustc_private)] #![feature(test)] #![warn(rustc::internal)] |
