Open fteppe opened 8 months ago
Have you tried wrapping Attribute::Athletics as i32
between parenthesis? That's what the error message says you should be doing
I did try that, it generates even more errors.
error: expected identifier, found keyword `as`
--> src\player\character_sheet.rs:17:39
|
17 | Atheltics = (Attribute::Athletics as i32),
| ^^ expected identifier, found keyword
error: expected one of `!`, `(`, `)`, `,`, `...`, `..=`, `..`, `::`, `{`, or `|`, found keyword `as`
--> src\player\character_sheet.rs:17:39
|
17 | Atheltics = (Attribute::Athletics as i32),
| -^^ expected one of 10 possible tokens
| |
| help: missing `,`
error: expected one of `)`, `,`, `@`, or `|`, found `i32`
--> src\player\character_sheet.rs:17:42
|
17 | Atheltics = (Attribute::Athletics as i32),
| -^^^ expected one of `)`, `,`, `@`, or `|`
| |
| help: missing `,`
error: proc-macro derive produced unparsable tokens
--> src\player\character_sheet.rs:15:10
|
15 | #[derive(Property, Hash, PartialEq, Eq, Clone, Copy)]
| ^^^^^^^^
warning: unused imports: `AttributeBlock`, `Attribute`
--> src\player\creature_stats.rs:3:25
|
3 | use super::attributes::{AttributeBlock, Attribute};
| ^^^^^^^^^^^^^^ ^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0308]: mismatched types
--> src\player\character_sheet.rs:17:17
|
15 | #[derive(Property, Hash, PartialEq, Eq, Clone, Copy)]
| -------- this expression has type `i32`
16 | pub enum Skill {
17 | Atheltics = (Attribute::Athletics as i32),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `(_, _, _)`
|
= note: expected type `i32`
found tuple `(_, _, _)
It makes sense once you see the generated code, you'll have a
match
{
(Skill::Athletics as i32) => ...
And the compiler doesn't like that
Ah, that does make sense. The constant may be the best way to go about it then, yeah.
I try to do this, to create Skill as a subset of Attribute.
The error is as follow:
If we look at the expanded macro where we replace
Attribute as i32
=>1
:// Recursive expansion of Property macro // ======================================
set_property
is where we get issues withAttribute::Athletics as i32
I proposed one way to do it: in
set_property
generate aconst ATHELTICS_I32_VAL : i32 = Attribute::Athletics as i32;
and match against that.Another proposed solution was to use if guards instead :