A library for creating enum sets that are stored as compact bit sets. The code is based on
the [enumset
] crate, except that the backing store used is an array of usize
. This enables
use with enums with large number of variants. The API is very similar to that of enumset
.
For serde support, enable the serde
feature.
Defining enums for use with BigEnumSet
Enums to be used with [BigEnumSet
] should be defined using #[derive(BigEnumSetType)]
:
# use *;
For more information on more advanced use cases, see the documentation for [BigEnumSetType
].
Working with BigEnumSet
s
BigEnumSets can be constructed via [BigEnumSet::new()
] like a normal set. In addition,
#[derive(BigEnumSetType)]
creates operator overloads that allow you to create BigEnumSets like so:
# use *;
#
let new_set = A | C | G;
assert_eq!;
All bitwise operations you would expect to work on bitsets also work on both BigEnumSets and
enums with #[derive(BigEnumSetType)]
:
# use *;
#
// Intersection of sets
assert_eq!;
assert_eq!;
assert_eq!;
// Symmetric difference of sets
assert_eq!;
assert_eq!;
// Difference of sets
assert_eq!;
// Complement of sets
assert_eq!;
The [big_enum_set!
] macro allows you to create BigEnumSets in constant contexts:
# use *;
#
const CONST_SET: = big_enum_set!;
assert_eq!;
Mutable operations on the [BigEnumSet
] work similarly to Rust's builtin sets:
# use *;
#
let mut set = new;
set.insert;
set.insert_all;
assert!;
assert!;
assert_eq!;