-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to use EitherOrBoth<T> to mean the same as EitherOrBoth<T, T> #719
Conversation
Hi there, thanks for the idea. Honest question: Does this - apart from avoiding a repeated type - enable something that could not be done with |
No, I was just trying to avoid the repeated type, which can be bothersome when it's long. |
e974219
to
e347885
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few places in our tests that could take advantage of this change:
Lines 59 to 98 in 0897f56
let expected_result: Vec<EitherOrBoth<u32, u32>> = vec![ | |
EitherOrBoth::Right(1), | |
EitherOrBoth::Right(2), | |
EitherOrBoth::Right(3), | |
EitherOrBoth::Left(4), | |
EitherOrBoth::Left(5), | |
EitherOrBoth::Left(6), | |
]; | |
let actual_result = merge_join_by(left, right, |l, r| l.cmp(r)).collect::<Vec<_>>(); | |
assert_eq!(expected_result, actual_result); | |
} | |
#[test] | |
fn interspersed_left_and_right() { | |
let left: Vec<u32> = vec![1, 3, 5]; | |
let right: Vec<u32> = vec![2, 4, 6]; | |
let expected_result: Vec<EitherOrBoth<u32, u32>> = vec![ | |
EitherOrBoth::Left(1), | |
EitherOrBoth::Right(2), | |
EitherOrBoth::Left(3), | |
EitherOrBoth::Right(4), | |
EitherOrBoth::Left(5), | |
EitherOrBoth::Right(6), | |
]; | |
let actual_result = merge_join_by(left, right, |l, r| l.cmp(r)).collect::<Vec<_>>(); | |
assert_eq!(expected_result, actual_result); | |
} | |
#[test] | |
fn overlapping_left_and_right() { | |
let left: Vec<u32> = vec![1, 3, 4, 6]; | |
let right: Vec<u32> = vec![2, 3, 4, 5]; | |
let expected_result: Vec<EitherOrBoth<u32, u32>> = vec![ | |
EitherOrBoth::Left(1), | |
EitherOrBoth::Right(2), | |
EitherOrBoth::Both(3, 3), | |
EitherOrBoth::Both(4, 4), | |
EitherOrBoth::Right(5), | |
EitherOrBoth::Left(6), | |
]; |
Can you modify them accordingly?
e347885
to
4e9fc6b
Compare
No description provided.