rustonaut / vec1

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

Add an optional 'serde' feature. #4

Closed mjkillough closed 6 years ago

mjkillough commented 6 years ago

Add an optional 'serde' feature, which provides Serialize and Deserialize implementations for Vec1. The Deserialize implementation ensures that an error is returned if the sequence is empty.

We currently have a Vec inside a struct that derives Serialize/Deserialize which has run-time checks to ensure the Vec is non-empty. We'd love to be able to replace our use with Vec1, while retaining the ability to derive these traits automatically.

I investigated implementing this outside of the crate, but it created awkward ergonomics. It seems most crates choose to provide these implementations themselves behind a serde feature flag.

meh commented 6 years ago

Seems like the most sensible option, thanks!

mjkillough commented 6 years ago

Thanks for the quick response!

mjkillough commented 6 years ago

@meh - Would you be able to make a new release with these changes? That'd allow us to use these changes in our project without relying on a Git dependency.

rustonaut commented 6 years ago

Ok, will be done in a view minutes

On Tue, Jul 24, 2018, 15:56 Michael Killough notifications@github.com wrote:

@meh https://github.com/meh - Would you be able to make a new release with these changes? That'd allow us to use these changes in our project without relying on a Git dependency.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/1aim/vec1/pull/4#issuecomment-407415473, or mute the thread https://github.com/notifications/unsubscribe-auth/AHR0kWoDlY1qgZZIgfFMk-dmy8MMYRX6ks5uJyd8gaJpZM4VVBpD .

rustonaut commented 6 years ago

Done, published as version 1.1.0

On Tue, Jul 24, 2018 at 4:01 PM Philipp Korber philippkorber@gmail.com wrote:

Ok, will be done in a view minutes

On Tue, Jul 24, 2018, 15:56 Michael Killough notifications@github.com wrote:

@meh https://github.com/meh - Would you be able to make a new release with these changes? That'd allow us to use these changes in our project without relying on a Git dependency.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/1aim/vec1/pull/4#issuecomment-407415473, or mute the thread https://github.com/notifications/unsubscribe-auth/AHR0kWoDlY1qgZZIgfFMk-dmy8MMYRX6ks5uJyd8gaJpZM4VVBpD .

mjkillough commented 6 years ago

❤️ Amazing! Thanks so much.