-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Leverage &mut in OnceLock when possible #149469
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
base: main
Are you sure you want to change the base?
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use |
| debug_assert!(self.is_initialized()); | ||
|
|
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.
Already checked in get_unchecked
| if self.get_mut().is_none() { | ||
| self.initialize(f)?; | ||
| } | ||
| debug_assert!(self.is_initialized()); |
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.
Already checked in get_unchecked_mut
|
|
||
| #[inline] | ||
| fn is_initialized(&self) -> bool { | ||
| fn initialized(&self) -> bool { |
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.
Aligned with initialized_mut.
is_initialized_mut doesn't follow some idioms that is_xxx would typically take &self.
Signed-off-by: tison <[email protected]>
| fn initialized_mut(&mut self) -> bool { | ||
| // `state()` does not perform an atomic load, so prefer it over `is_complete()`. | ||
| let state = self.once.state(); | ||
| match state { | ||
| OnceExclusiveState::Complete => true, | ||
| _ => false, | ||
| } | ||
| } |
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.
This is what LazyLock already does.
|
r? @yoshuawuyts |
|
Failed to set assignee to
|
|
Thanks for the ping @tisonkun, though I don't think I'm the right person to review this PR. |
Yeah .. Do you know where to find the right person? I remember you as an experienced async Rust developer and consider that you can give a review on whether the changes are reasonable. rustbot auto selects @Mark-Simulacrum but IIRC he is busy on Rust releases and builds. Thus I hope we can expand the bandwidth with other proper reviewer. |
|
I continue to actively review PRs, typically on a weekly basis. Please be patient with our reviewer pool. |
See comments inline.