-
Notifications
You must be signed in to change notification settings - Fork 2
Employ idiomatic code within DOL test #743
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
Employ idiomatic code within DOL test #743
Conversation
let obs_table_object = match obs_tab.remote.incoming_obs.iter().nth(0) { | ||
Some(obj) => obj, | ||
None => panic!("No elements present within obversation table"), | ||
}; |
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.
You can achieve the same with less code via:
let obs_table_object = match obs_tab.remote.incoming_obs.iter().nth(0) { | |
Some(obj) => obj, | |
None => panic!("No elements present within obversation table"), | |
}; | |
let obs_table_object = obs_tab.remote.incoming_obs.iter().nth(0).expect("No elements present within obversation table"); |
Looks like you hit a lint error. To validate locally, you can either do the most exhaustive check similar to what is run in CI: |
let obs_table_object = match obs_tab.local.incoming_obs.iter().next() { | ||
Some(obj) => obj, | ||
None => panic!("No elements present within obversation table"), | ||
}; |
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.
Just use .expect(..)
here, it's intended for exactly this purpose.
let obs_table_object = match obs_tab.local.incoming_obs.iter().next() { | |
Some(obj) => obj, | |
None => panic!("No elements present within obversation table"), | |
}; | |
let obs_table_object = obs_tab | |
.local | |
.incoming_obs | |
.iter() | |
.next() | |
.expect("No elements present within obversation table"); |
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.
Good thinking. Done
@achubbic-snav merge away |
No description provided.