-
-
Save anonymous/17b1b418713e676d5cea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Eq | |
pub fn seq_eq<A: Eq, T: Iterator<A>>(mut a: T, mut b: T) -> bool { | |
loop { | |
match (a.next(), b.next()) { | |
(None, None) => return true, | |
(None, _) | (_, None) => return false, | |
(Some(x), Some(y)) => if !x.eq(&y) { return false }, | |
} | |
} | |
} | |
/// Neq | |
pub fn seq_ne<A: Eq, T: Iterator<A>>(mut a: T, mut b: T) -> bool { | |
loop { | |
match (a.next(), b.next()) { | |
(None, None) => return false, | |
(None, _) | (_, None) => return true, | |
(Some(x), Some(y)) => if x.ne(&y) { return true }, | |
} | |
} | |
} | |
/// Less Than | |
pub fn seq_lt<A: Eq + Ord, T: Iterator<A>>(mut a: T, mut b: T) -> bool { | |
loop { | |
match (a.next(), b.next()) { | |
(None, None) => return false, | |
(None, _ ) => return true, | |
(_ , None) => return false, | |
(Some(x), Some(y)) => if !x.eq(&y) { return x.lt(&y) }, | |
} | |
} | |
} | |
/// Less Than or Equal | |
pub fn seq_le<A: Eq + Ord, T: Iterator<A>>(mut a: T, mut b: T) -> bool { | |
loop { | |
match (a.next(), b.next()) { | |
(None, None) => return true, | |
(None, _ ) => return true, | |
(_ , None) => return false, | |
(Some(x), Some(y)) => if !x.eq(&y) { return x.le(&y) }, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment