arrayvec icon indicating copy to clipboard operation
arrayvec copied to clipboard

Feature Request: ArrayVec that is Copy

Open mitchmindtree opened this issue 8 years ago • 13 comments

I'm considering using an ArrayVec<[_; 9]> as a small stack to keep track of pressed buttons on a mouse in conrod, however I noticed that it does not impl Copy. Seeing as it has a fixed-size, shouldn't deriving Copy be ok? Or is there some other boundary stopping this?

mitchmindtree avatar Mar 02 '16 12:03 mitchmindtree

It's a relevant question. ArrayVec implements Drop, which precludes Copy.

I have considered making a Copy-only ArrayVec, but most of the hard things this library does are for the non-Copy part to be correct. The Copy case is simple, so a regular array is often enough.

bluss avatar Mar 02 '16 13:03 bluss

Would you accept a CopyArrayVec pull-request?

WiSaGaN avatar Apr 22 '16 06:04 WiSaGaN

I'm not sure, it requires duplicating the whole thing. As said above, the most interesting things ArrayVec does is handle the non-Copy case correctly.

I guess this is not what you want, but maybe specialization (unstable feature) can be used to make ArrayVec Copy exactly when its elements are Copy.

bluss avatar Apr 23 '16 09:04 bluss

a PoC of copy-specialization works. This is the ideal approach since it transparently removes the overhead of non-copy arrayvecs (overwrite in drop etc). The use of unstable features is rather non-ideal though.

bluss avatar Apr 23 '16 10:04 bluss

This issue isn't very high priority for me, I'm happy waiting until specialization stabilises if that suits you best :+1:

mitchmindtree avatar Apr 23 '16 11:04 mitchmindtree

We don't even know if specialization will allow this, but we'll see.

bluss avatar Apr 25 '16 10:04 bluss

It sounds like this is no longer just a question but a feature request?

bluss avatar Apr 25 '16 10:04 bluss

I'm not sure that this needs a breaking change.

tbu- avatar Mar 18 '17 12:03 tbu-

arrayvec as a crate needs it. It's part of clearing the air before adding new features, if you will.

bluss avatar Mar 18 '17 13:03 bluss

Where the most significant breaking change is the change of minimum Rust version

bluss avatar Mar 18 '17 13:03 bluss

What is the status of this feature?

c410-f3r avatar Jun 23 '19 18:06 c410-f3r

Is this maybe easier to do now with the new array based implementation in 0.7?

smessmer avatar Apr 10 '21 06:04 smessmer

I’d be interested in this feature, is #193 on the right way to be merged ? thanks :)

pwnorbitals avatar Sep 14 '22 15:09 pwnorbitals