Don't compare ast::Visibility by stringifying

This commit is contained in:
Lukas Tobias Wirth 2021-05-20 17:27:51 +02:00
parent 8bb37737c9
commit da7f1eb756
4 changed files with 74 additions and 6 deletions

View file

@ -140,6 +140,34 @@ impl JodChild {
}
}
// feature: iter_order_by
// Iterator::eq_by
pub fn iter_eq_by<I, I2, F>(this: I2, other: I, mut eq: F) -> bool
where
I: IntoIterator,
I2: IntoIterator,
F: FnMut(I2::Item, I::Item) -> bool,
{
let mut other = other.into_iter();
let mut this = this.into_iter();
loop {
let x = match this.next() {
None => return other.next().is_none(),
Some(val) => val,
};
let y = match other.next() {
None => return false,
Some(val) => val,
};
if !eq(x, y) {
return false;
}
}
}
#[cfg(test)]
mod tests {
use super::*;