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

Made ArrayVec::new and ArrayString::new const fns #181

Merged
merged 4 commits into from
Mar 29, 2021

Conversation

rodrimati1992
Copy link
Contributor

@rodrimati1992 rodrimati1992 commented Mar 28, 2021

Followup to this comment: #93 (comment)

Fixes #93

rodrimati1992 and others added 3 commits March 28, 2021 14:48
Added utils module with a `MaybeUninit` helper type to construct `[MaybeUninit<T>; N]`

Removed all uses of the "unstable-const-fn" feature, and documented it as being deprecated.

Changed `assert_capacity_limit` macro to work in const contexts.
Updated the capacity panic test
@bluss
Copy link
Owner

bluss commented Mar 28, 2021

Nice, thanks! Instead of commenting, I just pushed a tweak to the formatting and wording for the feature flag. Thanks for remembering to update that.

@bluss
Copy link
Owner

bluss commented Mar 28, 2021

I considered this, as a follow-up to your solution:

[(); u32::MAX as usize /*ArrayVec: largest supported capacity is u32::MAX*/][$cap]

It also seems to work, but here I'd be worried about compiler quirks that would give problems for such a big array (even if it has 0 size in memory), for example in debuggers.

@rodrimati1992
Copy link
Contributor Author

rodrimati1992 commented Mar 28, 2021

I have the same concern with instantiating long zero-sized arrays.

For example, if this ever happens again: rust-lang/rust#68010

@bluss bluss merged commit 366c5da into bluss:master Mar 29, 2021
@bluss
Copy link
Owner

bluss commented Mar 29, 2021

Thanks. It's quite valuable for us to get off nightly features, even if the usage was very limited here.

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.

Give ArrayVec a const-fn constructor
2 participants