aboutsummaryrefslogtreecommitdiff
path: root/crates/stdx
diff options
context:
space:
mode:
authorLukas Tobias Wirth <[email protected]>2021-05-20 16:27:51 +0100
committerLukas Tobias Wirth <[email protected]>2021-05-20 16:45:59 +0100
commitda7f1eb756ba849b70ccb7e6c961ccf233e19099 (patch)
treedcb4766c1dbd85188ebea29a2d6f9f48d369a76c /crates/stdx
parent8bb37737c9e8b7a390ae29d5fb0daaeeb495d2b5 (diff)
Don't compare ast::Visibility by stringifying
Diffstat (limited to 'crates/stdx')
-rw-r--r--crates/stdx/src/lib.rs28
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
145pub fn iter_eq_by<I, I2, F>(this: I2, other: I, mut eq: F) -> bool
146where
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)]
144mod tests { 172mod tests {
145 use super::*; 173 use super::*;