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

Make SmallVec::new const #263

Open
Rua opened this issue Jun 30, 2021 · 1 comment
Open

Make SmallVec::new const #263

Rua opened this issue Jun 30, 2021 · 1 comment

Comments

@Rua
Copy link

Rua commented Jun 30, 2021

I don't know if this is possible, but it would definitely be helpful!

@mbrubeck
Copy link
Collaborator

mbrubeck commented Jul 6, 2021

This should be easier to implement after #240 is complete. I have added this to our roadmap for smallvec 2.0 (#183).

TimLuq added a commit to TimLuq/rust-smallvec that referenced this issue Sep 24, 2021
TimLuq added a commit to TimLuq/rust-smallvec that referenced this issue Sep 24, 2021
bors-servo added a commit that referenced this issue Sep 28, 2021
Added feature `const_new` which enables `SmallVec::new_const()`

As I wasn't alone in finding a use for having a `const` version of `new` (see #263) I decided to make a PR for it.

This adds a new feature flag `const_new` (nightly only) which exposes an alternative `new` function: `pub const unsafe fn new_const() -> SmallVec<A>`.

Nightly is needed for the binding `A: Array`, which could be worked around if the strict requirement is dropped from the `struct` declarations and moved only to the existing `impl`s.

If the maintainers wish for another solution for this I'll be happy to make a few more commits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants