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

Refactor UpstreamEndpoints retain to return enum #146

Closed
markmandel opened this issue Nov 25, 2020 · 1 comment · Fixed by #245
Closed

Refactor UpstreamEndpoints retain to return enum #146

markmandel opened this issue Nov 25, 2020 · 1 comment · Fixed by #245
Labels
good first issue Good for newcomers kind/cleanup Refactoring code, fixing up documentation, etc

Comments

@markmandel
Copy link
Member

pub fn retain<F>(&mut self, predicate: F) -> Result<(), AllEndpointsRemovedError>

We want to change the function signature to return an enum rather than a Result so that it doesn't seem like something bad has happened when we catch an error.

Maybe something like:

enum RetainResult {
   Empty
   Ok
}

⬆️ Sacrificial draft. Change as necessary.

Then we can also add extra states if needed down the line.

@markmandel markmandel added good first issue Good for newcomers kind/cleanup Refactoring code, fixing up documentation, etc labels Nov 25, 2020
@iffyio
Copy link
Collaborator

iffyio commented Nov 25, 2020

Also lets include must_use in the enum to enforce that the caller doesn't ignore the returned result since that can otherwise introduce bugs in their code if e.g the call rejected the operation while they assumed it succeeded.
https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/cleanup Refactoring code, fixing up documentation, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants