Lymia / enumset

A library for compact bit sets containing enums.
Apache License 2.0
91 stars 35 forks source link

Add optional feature which implements ser/de for EnumSet. #5

Closed boxdot closed 5 years ago

Lymia commented 5 years ago

Do you have a particular reason to want to always serialize EnumSet<T> using an u128, instead of using the existing Serialize/Deserialize for the EnumSet's underlying representation?

While this would cause the encoding to possibly change when adding variants with some encoders, it'd also make it far more compact with libraries like bincode and avoid serializing an u128 when possible. (You need the i128 feature in bincode, for example.)

I think using the underlying repr is the better approach, but I'm wondering about your use case.

boxdot commented 5 years ago

Hey, thanks for merging. My use case is actually json and bincode at the same time, but the bitset is not used in Vec's or other containers, so I went for an easy solution. I would like to reduce the size of serialized data by using the underlying repr of T if is it possible in a consecutive PR. What do you think?

boxdot commented 5 years ago

I just saw that you already added tests, release note and changed the underlying repr. Thanks!