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