rustonaut / vec1

Rust `Vec<T>` wrapper that gurantees to contain at least 1 element
Apache License 2.0
90 stars 15 forks source link

Support for smallvec #22

Closed little-dude closed 3 years ago

little-dude commented 3 years ago

Hey @rustonaut :)

Thanks for the library, it's very useful!

I'd like to have a vec1 backed by a SmallVec. Is this something you'd be willing to support, if I provide the PR? Maybe as an optional feature?

rustonaut commented 3 years ago

Sounds good, but give me a moment to think about how to best do it.

On Wed, Jan 27, 2021, 15:25 Corentin Henry notifications@github.com wrote:

Hey @rustonaut https://github.com/rustonaut :)

Thanks for the library, it's very useful!

I'd like to have a vec1 backed by a SmallVec. Is this something you'd be willing to support, if I provide the PR? Maybe as an optional feature?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rustonaut/vec1/issues/22, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2HJEJ7PLHKIMJ3WRRUVOLS4AO3ZANCNFSM4WVLC2JQ .

rustonaut commented 3 years ago

There is an initial implementation in the smallvec_v1 branch.

But doc still needs to be updated and I will use some macro trick to de-duplicate many methods which are implemented more or less the same way for Vec1 and SmallVec1.

rustonaut commented 3 years ago

Oh and various features of smallvec (no_std, serde, write, const_generics) are not yet directly supported others are internal only and do not need support but probably should still be re-exported (union, specialization, may_dangle).

little-dude commented 3 years ago

Hey :)

Sorry for the long delay here. I took a look at the smallvec_v1 branch. It looks good. Anything I can help with? Regarding the features, I'd need the serde one, maybe I can add this as an optional feature?

little-dude commented 3 years ago

Oh this is already in the nightly branch. Looking at the Cargo.toml it looks like enabling serde already works.

rustonaut commented 3 years ago

Just enable serde on the vec1 create, that makes SmallVec1 serializable.

(Through it doesn't enable smallvec/serde.)

I originally wanted to push a new version to crates.io today but my computer stoped working (might be easy to fix,idk) so I'm not sure this will happen today. On Thu, Feb 11, 2021, 15:14 Corentin Henry notifications@github.com wrote:

Oh this is already in the nightly branch. Looking at the Cargo.toml it looks like enabling serde on smallvec is enough for SmallVec1 to implement Serialize/Deserialize ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rustonaut/vec1/issues/22#issuecomment-777488343, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2HJEMB73QEHDWPEEHH5L3S6PQ3DANCNFSM4WVLC2JQ .

little-dude commented 3 years ago

No worries regarding the release, I'll fetch the crate from github. Thanks a ton @rustonaut !

rustonaut commented 3 years ago

Published new version v1.8.0

Containing smallvec support and a lot of other improvements.

little-dude commented 3 years ago

Awesome, thanks a lot!