mirror of
https://github.com/danog/strum.git
synced 2024-12-02 09:27:57 +01:00
e9d3b59a80
* Re-exportable macros * Rename derive attribute to `Crate` * Add unit tests * Test nested module * Rename derive attribute to `crate` * cargo fmt
43 lines
755 B
Rust
43 lines
755 B
Rust
use strum::{EnumCount, EnumIter, IntoEnumIterator};
|
|
|
|
#[derive(Debug, EnumCount, EnumIter)]
|
|
enum Week {
|
|
Sunday,
|
|
Monday,
|
|
Tuesday,
|
|
Wednesday,
|
|
Thursday,
|
|
Friday,
|
|
Saturday,
|
|
}
|
|
|
|
#[test]
|
|
fn simple_test() {
|
|
assert_eq!(7, Week::COUNT);
|
|
assert_eq!(Week::iter().count(), Week::COUNT);
|
|
}
|
|
|
|
#[test]
|
|
fn crate_module_path_test() {
|
|
pub mod nested {
|
|
pub mod module {
|
|
pub use strum;
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, EnumCount, EnumIter)]
|
|
#[strum(crate = "nested::module::strum")]
|
|
enum Week {
|
|
Sunday,
|
|
Monday,
|
|
Tuesday,
|
|
Wednesday,
|
|
Thursday,
|
|
Friday,
|
|
Saturday,
|
|
}
|
|
|
|
assert_eq!(7, Week::COUNT);
|
|
assert_eq!(Week::iter().count(), Week::COUNT);
|
|
}
|