Skip to content

Conversation

achubbic-snav
Copy link
Contributor

No description provided.

@achubbic-snav achubbic-snav self-assigned this Sep 19, 2022
@achubbic-snav achubbic-snav changed the title Eliminated for loop within test [DEVINFRA-895] Employ idiomatic code within DOL test Sep 19, 2022
Comment on lines 409 to 412
let obs_table_object = match obs_tab.remote.incoming_obs.iter().nth(0) {
Some(obj) => obj,
None => panic!("No elements present within obversation table"),
};
Copy link
Contributor

@silverjam silverjam Sep 19, 2022

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:

Suggested change
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");

@john-michaelburke
Copy link
Collaborator

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: cargo make check-all or you can run just the rust specific linter cargo make rust-lint

Comment on lines 359 to 362
let obs_table_object = match obs_tab.local.incoming_obs.iter().next() {
Some(obj) => obj,
None => panic!("No elements present within obversation table"),
};
Copy link
Contributor

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.

Suggested change
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");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking. Done

@silverjam
Copy link
Contributor

@achubbic-snav merge away

@achubbic-snav achubbic-snav merged commit 7272765 into main Sep 30, 2022
@achubbic-snav achubbic-snav deleted the DEVINFRA-895_Employ-idiomatic-code-in-handle-obs-test branch September 30, 2022 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants