strand_cam_enum_iter/lib.rs
1//! A small utility crate to provide [`EnumIter`] trait for iterating over enums
2//! in the [Strand Camera](https://strawlab.org/strand-cam) ecosystem.
3
4/// Allows collecting all variants of an enum.
5///
6/// See also the
7/// [`IntoEnumIterator`](https://docs.rs/strum/0.27.1/strum/trait.IntoEnumIterator.html)
8/// trait of the [`strum`](https://docs.rs/strum) crate for a version which can
9/// be automatically derived.
10pub trait EnumIter
11where
12 Self: Sized,
13{
14 /// Returns a vector containing all variants of the enum.
15 fn variants() -> Vec<Self>;
16}
17
18impl EnumIter for bool {
19 fn variants() -> Vec<Self> {
20 vec![true, false]
21 }
22}