Skip to content
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

Method TicketStatus.is_confirmed can be simplified #3

Open
cleanunicorn opened this issue Oct 8, 2021 · 0 comments
Open

Method TicketStatus.is_confirmed can be simplified #3

cleanunicorn opened this issue Oct 8, 2021 · 0 comments

Comments

@cleanunicorn
Copy link
Member

Description

The TicketStatus implements method is_confirmed.

// Pass Option::None to ignore generation
pub fn is_confirmed(&self, opt_current_generation: Option<u8>) -> bool {
match *self {
TicketStatus::Confirmed { generation } => {
if let Some(current_generation) = opt_current_generation {
generation == current_generation
} else {
true
}
}
_ => false,
}
}

This method is used in 2 cases:

if !ticket_status.is_confirmed(None) {

if !ticket_status.is_confirmed(None) {

In both cases the argument is None. The additional complexity in the method is never used, thus the method can be simplified.

Recommendation

Simplify the method if the additional complexity is never used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant