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

feat+refactor: Bump MSRV to 1.83.0 and maximize const #294

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Daniel-Aaron-Bloom
Copy link

@Daniel-Aaron-Bloom Daniel-Aaron-Bloom commented Feb 23, 2025

Find every fn which can be const (as of 1.83.0) and make it so. This involved moving all the implementations out of the ArrayVecImpl trait, which eventually left it unused, so I removed it.

You could probably also remove MakeMaybeUninit and just have new_const call new if you wanted to.

@Daniel-Aaron-Bloom Daniel-Aaron-Bloom changed the title feat+refactor: Maximize const feat+refactor: Bump MSRV to 1.83.0 and maximize const Feb 23, 2025
@tbu-
Copy link
Collaborator

tbu- commented Mar 7, 2025

What's your motivation for this pull request? This currently raises the MSRV quite substantially, so it should have a good motivation, at the very least.

@Daniel-Aaron-Bloom
Copy link
Author

I made this crate, and doing that was my motivation.

The summary is: now that &mut is const-compatible, you can make almost everything in ArrayVec into a const fn. Having a mut ArrayVec at compile-time is extremely powerful.

For now I've just forked this crate as arrayvec-const, but that's basically just a hack.

@Daniel-Aaron-Bloom
Copy link
Author

Do you think this would be better served via a feature-flag?

@cmrschwarz
Copy link

cmrschwarz commented Mar 22, 2025

I would love if we could have something like this 👍 , honestly sooner rather than later as it blocks downstream libraries.

1.83 marks a huge shift in whats possible in const and anybody trying to currently use arrayvec
in programs that want to take advantage of that is just completely out of luck.

A minimal version of this that would be sufficient for libraries would be a const_as_mut_ptr feature flag that would opt in to 1.83. It would mark the following two functions as const (both of these are one liners so having a cfg'd duplicate should be acceptible):

  • as_mut_ptr
  • set_len
    This would expose enough of ArrayVecs internals for a downstream library / program willing to use unsafe to do what it needs to in const code.

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

Successfully merging this pull request may close these issues.

3 participants