data: IndexMap<String, IndexMap<String, Vec<Datum<String>>>>,
warn: &mut dyn FnMut(LegacyXmlWarning),
) -> BTreeMap<&str, Series> {
- let mut variables: Vec<&dyn Variable> = Vec::new();
- for child in &self.children {
- match child {
- VisChild::SourceVariable(source_variable) => variables.push(source_variable),
- VisChild::DerivedVariable(derived_variable) => variables.push(derived_variable),
- _ => (),
- }
- }
+ let mut variables: Vec<&dyn Variable> = self
+ .children
+ .iter()
+ .filter_map(|child| child.variable())
+ .collect();
let mut series = BTreeMap::<&str, Series>::new();
- while let n = variables.len()
- && n > 0
- {
+ while !variables.is_empty() {
+ let n = variables.len();
variables.retain(|variable| !variable.decode(&data, &mut series, warn));
-
if n == variables.len() {
warn(LegacyXmlWarning::UnresolvedDependencies(
variables
}
impl VisChild {
+ fn variable(&self) -> Option<&dyn Variable> {
+ match self {
+ VisChild::SourceVariable(source_variable) => Some(source_variable),
+ VisChild::DerivedVariable(derived_variable) => Some(derived_variable),
+ _ => None,
+ }
+ }
fn style(&self) -> Option<&Style> {
match self {
Self::Style(style) => Some(style),