-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
values()
method and document all methods in UnitEnum macro
- Loading branch information
1 parent
ac805fd
commit cffef75
Showing
7 changed files
with
81 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Unreleased | ||
|
||
# Version 1.1.0 (2024-06-27) | ||
|
||
- Add `values()` method and document all methods in UnitEnum macro | ||
|
||
# Version 1.0.0 (2024-03-17) | ||
|
||
- Initial Revision |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "unit-enum" | ||
version = "1.0.0" | ||
version = "1.1.0" | ||
authors = ["Renaud Denis <[email protected]>"] | ||
description = "A procedural macro for deriving ordinal methods in unit-like enums for Rust." | ||
license = "MIT OR Apache-2.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
use unit_enum::UnitEnum; | ||
|
||
#[derive(Debug, Clone, Copy, UnitEnum)] | ||
#[derive(Debug, Clone, Copy, PartialEq, UnitEnum)] | ||
enum Color { | ||
Red, | ||
Green, | ||
Blue | ||
} | ||
|
||
fn main() { | ||
println!("Ordinal of Green: {:?}", Color::Green.ordinal()); | ||
println!("Value of ordinal 2: {:?}", Color::from_ordinal(2)); | ||
println!("Number of Color variants: {:?}", Color::len()); | ||
println!("Ordinal of Green: {:?}", Color::Green.ordinal()); | ||
// Ordinal of Green: 1 | ||
|
||
println!("Value of ordinal 2: {:?}", Color::from_ordinal(2)); | ||
// Value of ordinal 2: Some(Blue) | ||
|
||
println!("Number of Color variants: {:?}", Color::len()); | ||
// Number of Color variants: 3 | ||
|
||
println!("List of Color variants: {:?}", Color::values().collect::<Vec<_>>()); | ||
// List of Color variants: [Red, Green, Blue] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters