-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Make Vec::len() and Vec::is_empty() const #78648
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
@jplatte it means it has to go through FCP instead of only having a single reviewer approve. These seem like good candidates for |
Did you run into a situation where having these as const fn is useful? Or is this only for consistency with |
I made a bunch of types' parameterless constructors const (for no immediate gain as it turned out, but it worked) and it made sense to me that the methods on these types that check for an all-default / empty instance would also be const, but that didn't work because of |
(cc @rust-lang/wg-const-eval) |
I seem to recall this was proposed before and we decided to wait until these methods are actually useful... but @oli-obk will probably remember better.^^ I personally do not think we should stabilize |
Previous iterations of this PR: #66462 and #65341 and some more discussion in #55278 (comment) We closed all such PRs before, maybe we should leave a comment on these functions informing future constifiers that we want to delay making them const fn until we have rust-lang/const-eval#20 (or until someone comes up with a use case) |
Oh, sure, we could make them unstably const fn and then mention in the tracking issue that we're blocking it on a use case being presented or const heap becoming that use case |
Oh, sorry for not being very diligent with looking for existing PRs. I did some searching but obviously not enough (maybe it was just issues). |
Since these can trivially be const, I applied
rustc_const_stable
right away. Is this okay?