Closed
Description
DerivedFrom registers are not generating getters for the EnumeratedVariants.
esp32-0.8.0 (generated using svd2rust v0.17.0 (714ed98 2020-06-09)):
// initial register
#[doc = "Reader of field `WDT_STG0`"]
pub type WDT_STG0_R = crate::R<u8, WDT_STG0_A>;
impl WDT_STG0_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u8, WDT_STG0_A> {
use crate::Variant::*;
match self.bits {
0 => Val(WDT_STG0_A::DISABLE),
1 => Val(WDT_STG0_A::INTERRUPT),
2 => Val(WDT_STG0_A::RESETCPU),
3 => Val(WDT_STG0_A::RESETSYSTEM),
4 => Val(WDT_STG0_A::RESETRTC),
i => Res(i),
}
}
// ..
// derived from:
#[doc = ""]
pub type WDT_STG1_A = WDT_STG0_A;
#[doc = "Reader of field `WDT_STG1`"]
pub type WDT_STG1_R = crate::R<u8, WDT_STG1_A>;
// WDT_STG1_R has the methods `.variant`
Essentially crate::R<u8, WDT_STG0_A>
has all variant method impls, and the derivedFrom versions are simply type alias to that.
However in esp32-0.9.0 (generated using svd2rust v0.17.0 (1a2bf65 2020-09-20)) :
#[doc = "Field `WDT_STG0` reader - "]
pub struct WDT_STG0_R(crate::FieldReader<u8, WDT_STG0_A>);
impl WDT_STG0_R {
pub(crate) fn new(bits: u8) -> Self {
WDT_STG0_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u8, WDT_STG0_A> {
use crate::Variant::*;
match self.bits {
0 => Val(WDT_STG0_A::DISABLE),
1 => Val(WDT_STG0_A::INTERRUPT),
2 => Val(WDT_STG0_A::RESETCPU),
3 => Val(WDT_STG0_A::RESETSYSTEM),
4 => Val(WDT_STG0_A::RESETRTC),
i => Res(i),
}
}
// .. other impls omitted fro brevity
// derived from:
#[doc = ""]
pub type WDT_STG1_A = WDT_STG0_A;
#[doc = "Field `WDT_STG1` reader - "]
pub struct WDT_STG1_R(crate::FieldReader<u8, WDT_STG1_A>);
impl WDT_STG1_R {
pub(crate) fn new(bits: u8) -> Self {
WDT_STG1_R(crate::FieldReader::new(bits))
}
}
// // WDT_STG1_R does NOT have the method `.variant`
Each derivedFrom is a new type, but as you can see it doesn't have the variant methods generated for it.
It seems to me like the methods should be generated for all derived from structs (duplicating code :() or go back to the trait alias method?