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

[CORE] added unreachable unwrap function to Option #134007

Closed
wants to merge 2 commits into from

Conversation

Cr0a3
Copy link

@Cr0a3 Cr0a3 commented Dec 7, 2024

Hi,
In this PR i added a function to Option which throws an unreachable exception, if the internal value is None.

Would this have use cases?

Yes, I want a feature like that for a very long time.
It would make development of some of my codegen libs easier.

Best wishes,
Toni

@rustbot
Copy link
Collaborator

rustbot commented Dec 7, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @workingjubilee (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 7, 2024
@rust-log-analyzer

This comment has been minimized.

@cyrgani
Copy link
Contributor

cyrgani commented Dec 7, 2024

See rust-lang/rfcs#3706 for a longer discussion of such a function and alternatives too.

@workingjubilee workingjubilee added S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 7, 2024
@workingjubilee
Copy link
Member

Please file an ACP.

@workingjubilee
Copy link
Member

As unwrap_unchecked exists, which is equivalent to a match which uses unreachable_unchecked on the None branch, I really don't think this is a good function to add as it just adds more confusion about what can be done with an option. You can use an extension trait to add your particular personal functions that you want.

If you didn't know about those functions before I told you about them, that's my point: the API is already too big for it to be easily learnable.

@Cr0a3
Copy link
Author

Cr0a3 commented Dec 8, 2024

As unwrap_unchecked exists, which is equivalent to a match which uses unreachable_unchecked on the None branch, I really don't think this is a good function to add as it just adds more confusion about what can be done with an option. You can use an extension trait to add your particular personal functions that you want.

If you didn't know about those functions before I told you about them, that's my point: the API is already too big for it to be easily learnable.

Ok, then I am going to close this pr

@Cr0a3 Cr0a3 closed this Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants