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

Add ArrayVecCopy V2 #261

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

Add ArrayVecCopy V2 #261

wants to merge 4 commits into from

Conversation

pYtoner
Copy link

@pYtoner pYtoner commented Feb 9, 2024

New version of closed: #193

Made a copy of ArrayVec (ArrayVecCopy) that can only hold Copy items.

This means copying all of its relevant functions and relevant tests.

Closes #32

@pYtoner pYtoner mentioned this pull request Feb 9, 2024
@pYtoner
Copy link
Author

pYtoner commented Feb 9, 2024

Unfortunately miri says there is UB in quite a few places.

Tests with UB are:

  1. test_retain - caused by ArrayVecCopy::retain
  2. test_drain_range_inclusive - caused by ArrayVecCopy::drain
  3. test_drain - caused by ArrayVecCopy::drain
  4. test_pop_at - caused by ArrayVecCopy::drain

After trying for a bit I am not going to fix this UB myself. I am not proficient enough with unsafe yet.

@bluss bluss self-requested a review March 7, 2024 19:28
Copy link
Collaborator

@tbu- tbu- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how to keep the whole thing maintainable. If possible, the arrayvec_copy module should be mostly kept in sync with the arrayvec module. Perhaps one could put up a diff plus some search/replace that generates the arrayvec_copy module?

@@ -1,6 +1,6 @@
[package]
name = "arrayvec"
version = "0.7.4"
version = "0.8.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a breaking change. Is there any?

@@ -42,6 +42,7 @@ harness = false
[features]
default = ["std"]
std = []
copy = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to gate this behind a feature.

mod arrayvec_copy;
#[cfg(feature = "copy")]
pub mod copy {
pub use crate::arrayvec_copy::{ArrayVecCopy, IntoIter, Drain};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps only keep the iterator types in here and expose the ArrayVecCopy globally.

@bluss bluss mentioned this pull request Oct 21, 2024
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.

Feature Request: ArrayVec that is Copy
2 participants