Initialize directly in From<T> for OnceLock<T>#158101
Merged
Merged
Conversation
There's no need to jump through all the hoops of `set` when we are creating a new `OnceLock` from scratch.
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
tgross35
approved these changes
Jun 18, 2026
Contributor
There was a problem hiding this comment.
Happened to see this from the ACP discussion,
r? me
@bors r+ rollup
Contributor
rust-timer
added a commit
that referenced
this pull request
Jun 19, 2026
Rollup merge of #158101 - cuviper:once_lock-from, r=tgross35 Initialize directly in `From<T> for OnceLock<T>` There's no need to jump through all the hoops of `set` when we are creating a new `OnceLock` from scratch.
github-actions Bot
pushed a commit
to rust-lang/stdarch
that referenced
this pull request
Jun 19, 2026
Rollup of 2 pull requests Successful merges: - rust-lang/rust#158026 (`RegionValues`: disable unnecessary range check) - rust-lang/rust#158101 (Initialize directly in `From<T> for OnceLock<T>`)
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jun 20, 2026
Use the direct `From` in `Clone for OnceLock<T>` This is a followup to rust-lang#158101 as again, the complexity of `set` is not necessary here, especially because we can now use that direct `From`. r? tgross35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's no need to jump through all the hoops of
setwhen we arecreating a new
OnceLockfrom scratch.