-
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 fn #66462
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @oli-obk |
#65341 aimed to add these last month, but it was closed due to |
Yea, we're going to delay making these const fn until someone has a use case. That said, I wonder if we can coerce a vec to a slice in const eval and call slice's len method |
Can't we use once_cell const a: Lazy<Vec<i8>> = Lazy::new(|| vec![1, 2, 3]); |
|
Ping from triage |
Closing for now. If you come up with a use case where these are needed, please create an issue for it so it can be discussed independently of an implementation |
Making these two functions const fn will improve the usability in constant context.
This also open the possibility of contify
String
functions with the same names.Maybe this is putting the cart before the horse, since we don't have const allocation yet and should be delayed till we have one