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

Restructure Paths::path_response #2309

Open
larseggert opened this issue Jan 7, 2025 · 0 comments
Open

Restructure Paths::path_response #2309

larseggert opened this issue Jan 7, 2025 · 0 comments

Comments

@larseggert
Copy link
Collaborator

larseggert commented Jan 7, 2025

I think that you can restructure this little piece of code to avoid the extra break.

let Some(primary) = self.migration_target.as_mut() else { break; }
if Rc::ptr_eq(target, primary) {
  let p = primary.take();
  mem::drop(self.select_primary(&p, now));
  return true;
}
break;

Once we're on 1.80 MSRV, we can use Option::take_if and simplify further.

if let Some(primary) = self.migration_target.take_if(|p| Rc::ptr_eq(target, p)) 
  mem::drop(self.select_primary(&primary, now));
  return true;
}
break;

Originally posted by @martinthomson in #2294 (comment)

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

No branches or pull requests

1 participant