We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using subenum 1.1.2 with Rust 1.77.2 (stable).
subenum
Please consider this, which compiles OK:
#[subenum(Fruit)] pub enum Food { #[subenum(Fruit)] Apple {}, }
The addition of the PartialEq trait to the derive clause results in a compiler error:
PartialEq
derive
#[subenum(Fruit)] #[derive(PartialEq)] pub enum Food { #[subenum(Fruit)] Apple {}, }
The error is:
error: expected expression, found `,` --> src/problem.rs:19:1 | 19 | #[subenum(Fruit)] | ^^^^^^^^^^^^^^^^^ | | | expected expression | while parsing the `match` arm starting here
The same error occurs for an empty tuple struct syntax as well:
#[subenum(Fruit)] #[derive(PartialEq)] pub enum Food { #[subenum(Fruit)] Apple (), // <--- empty tuple struct variant } // Compile Error: expected expression, found `,`
Adding a dummy struct field, or removing the struct variant or tuple struct syntax, makes the code compile again:
#[subenum(Fruit)] #[derive(PartialEq)] pub enum Food { #[subenum(Fruit)] Apple { dummy: i32, // <--- at least one field }, } // Compiles OK
Or:
#[subenum(Fruit)] #[derive(PartialEq)] pub enum Food { #[subenum(Fruit)] Apple (()), } // Compiles OK
#[subenum(Fruit)] #[derive(PartialEq)] pub enum Food { #[subenum(Fruit)] Apple, // <--- not an empty c-like struct or tuple struct variant } // Compiles OK
Changing the order of the macros also resolves the compiler error:
#[derive(PartialEq)] // <--- swapped #[subenum(Fruit)] // <--- swapped pub enum Food { #[subenum(Fruit)] Apple {}, } // Compiles OK
But this seems to cause other problems, like the PartialEq not actually being implemented for the subenums.
I don't think it's too uncommon to use empty struct or tuple variants, and it's certainly part of the language to do so.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Using
subenum
1.1.2 with Rust 1.77.2 (stable).Please consider this, which compiles OK:
The addition of the
PartialEq
trait to thederive
clause results in a compiler error:The error is:
The same error occurs for an empty tuple struct syntax as well:
Adding a dummy struct field, or removing the struct variant or tuple struct syntax, makes the code compile again:
Or:
Or:
Changing the order of the macros also resolves the compiler error:
But this seems to cause other problems, like the
PartialEq
not actually being implemented for the subenums.I don't think it's too uncommon to use empty struct or tuple variants, and it's certainly part of the language to do so.
The text was updated successfully, but these errors were encountered: