diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-20 17:05:54 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-20 17:05:54 +0100 |
commit | f86a9572f388292e0bf4b9a3df172a097f88b155 (patch) | |
tree | eeb9bcb3d64d31fcc7a3841439d4f6ee7380bfb5 /crates/stdx/src | |
parent | 7aab09ca6c62ee19528b0acf5b164d66f78575db (diff) | |
parent | da7f1eb756ba849b70ccb7e6c961ccf233e19099 (diff) |
Merge #8897
8897: minor: Don't compare ast::Visibility by stringifying r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Tobias Wirth <[email protected]>
Diffstat (limited to 'crates/stdx/src')
-rw-r--r-- | crates/stdx/src/lib.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 340fcacfa..18d5fadb9 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs | |||
@@ -140,6 +140,34 @@ impl JodChild { | |||
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | // feature: iter_order_by | ||
144 | // Iterator::eq_by | ||
145 | pub fn iter_eq_by<I, I2, F>(this: I2, other: I, mut eq: F) -> bool | ||
146 | where | ||
147 | I: IntoIterator, | ||
148 | I2: IntoIterator, | ||
149 | F: FnMut(I2::Item, I::Item) -> bool, | ||
150 | { | ||
151 | let mut other = other.into_iter(); | ||
152 | let mut this = this.into_iter(); | ||
153 | |||
154 | loop { | ||
155 | let x = match this.next() { | ||
156 | None => return other.next().is_none(), | ||
157 | Some(val) => val, | ||
158 | }; | ||
159 | |||
160 | let y = match other.next() { | ||
161 | None => return false, | ||
162 | Some(val) => val, | ||
163 | }; | ||
164 | |||
165 | if !eq(x, y) { | ||
166 | return false; | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
143 | #[cfg(test)] | 171 | #[cfg(test)] |
144 | mod tests { | 172 | mod tests { |
145 | use super::*; | 173 | use super::*; |