`const` `VecDeque` initialiser

I need to initialise a VecDeque in a const context, but VecDeque::new is not const. However, Vec::new is const. Vec and VecDeque are quite similar under the hood; is there anything stopping VecDeque from having a const initialiser?

If it is possible, how would I go about adding a PR to Rust, would I need to discuss it with someone prior? I've noticed other const functions have a rustc_const_stable attribute suggesting it's not as trivial as just adding the const keyword.

Current implementation does heap-allocate in new and has a concept of a minium capacity:

so it's harder than just declaring new const. You'd have to change the implementation to tolerate zero capacity.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.