irox_enums/lib.rs
1// SPDX-License-Identifier: MIT
2// Copyright 2023 IROX Contributors
3
4//!
5//! This crate contains derivable traits for enum types to make them a
6//! bit easier to use - more like Java enums
7//!
8
9#![no_std]
10
11pub use irox_enums_derive::*;
12extern crate alloc;
13
14pub type IntoIter<T> = alloc::vec::IntoIter<T>;
15
16///
17/// This trait allows an enum to return it's own 'name' - its identifier.
18///
19pub trait EnumName {
20 fn name(&self) -> &'static str;
21}
22
23///
24/// This trait allows an enum to return an iterable vector of it's elements.
25/// This trait is ONLY derivable on traits who's elements have NO fields
26///
27pub trait EnumIterItem {
28 type Item;
29 fn iter_items() -> IntoIter<Self::Item>;
30}