-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support non-literal discriminant values
While preserving favouring literal values where possible.
- Loading branch information
1 parent
7acc582
commit 0c7a795
Showing
4 changed files
with
208 additions
and
56 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
num_enum/tests/try_build/compile_fail/alternative_exprs.rs
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,13 @@ | ||
const THREE: u8 = 3; | ||
|
||
#[derive(num_enum::TryFromPrimitive)] | ||
#[repr(i8)] | ||
enum Numbers { | ||
Zero = 0, | ||
#[num_enum(alternatives = [-1, 2, THREE])] | ||
One = 1, | ||
} | ||
|
||
fn main() { | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
num_enum/tests/try_build/compile_fail/alternative_exprs.stderr
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,5 @@ | ||
error: Only literals are allowed as num_enum alternate values | ||
--> tests/try_build/compile_fail/alternative_exprs.rs:7:39 | ||
| | ||
7 | #[num_enum(alternatives = [-1, 2, THREE])] | ||
| ^^^^^ |
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