Vector of enums
I have an XML file that is something like this:
<Subsystems>
<EngineSubsystem><!-- ... --></EngineSubsystem>
<SensorSubsystem><!-- ... --></SensorSubsystem>
<SomeOtherSubsystem><!-- ... --></SomeOtherSubsystem>
</Subsystems>
The corresponding struct has:
#[derive(Debug, Clone, XmlRead, PartialEq)]
pub enum SubsystemConfig {
#[xml(tag = "EngineSubsystem")]
EngineSubsystemConfig(EngineSubsystemConfig),
#[xml(tag = "SensorSubsystemConfig")]
SensorSubsystemConfig(SensorSubsystemConfig),
#[xml(tag = "SomeOtherSubsystem")]
SomeOtherSubsystem(SomeOtherSubsystem),
}
#[derive(Debug, Clone, XmlRead, PartialEq)]
pub struct SubsystemConfig {
#[xml(tag = "Subsystems")]
pub subsystems: Vec<SubsystemConfig>
}
This however does not work. Is there some other way of doing this?
Slightly unrelated question. For Vecs in general, is it possible to have a data-structure like:
<Parent>
<Children>
<Child>1</Child>
<Child>2</Child>
<Child>3</Child>
</Children>
</Parent>
mapped to something like:
pub struct Parent {
children: Vec<Child>
}