Hi,
I'd like to be able to set a "default" field value that catches unspecified values.
Not sure about the syntax, maybe Default(_) or Default = _.
Here is an example that would catch unknown values for easier error reporting:
register_bitfields![u16,
#[doc = "Host Controller Version Register (Offset 0FEh RO)"]
pub HostControllerVersion [
#[doc = "Specification Version Number"]
SPEC OFFSET(0) NUMBITS(8) [
#[doc = "SD Host Specification Version 1.00"]
Version100 = 0,
#[doc = "Unknown Specification Version"]
Unknown(_)
],
#[doc = "Vendor Version Number"]
REV OFFSET(8) NUMBITS(8) [],
],
];
It could also be the opposite use case, where we capture the values that really matter in the "default" field:
register_bitfields![u16,
pub Example [
FIELD OFFSET(0) NUMBITS(8) [
Reserved = 0b11111111,
Value(_)
],
],
];
Note that this enum cannot be #[repr($valtype)] since it will contain an entry with a $valtype inside (probably).
The comment of the repr indicates it's not a problem: // so that values larger than isize::MAX can be stored
Since this is about the field values section, note that I also mentioned here another use case for that section (representing a subregister).
No idea how the debug text should be in that particular use case, so didn't create an issue.
Hi,
I'd like to be able to set a "default" field value that catches unspecified values.
Not sure about the syntax, maybe
Default(_)orDefault = _.Here is an example that would catch unknown values for easier error reporting:
It could also be the opposite use case, where we capture the values that really matter in the "default" field:
Note that this enum cannot be
#[repr($valtype)]since it will contain an entry with a$valtypeinside (probably).The comment of the repr indicates it's not a problem:
// so that values larger than isize::MAX can be storedSince this is about the field values section, note that I also mentioned here another use case for that section (representing a subregister).
No idea how the debug text should be in that particular use case, so didn't create an issue.