Skip to content

Commit

Permalink
improvements for iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
jack committed Jun 22, 2024
1 parent 25c28b5 commit d7eac9a
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions src/interface/iimpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,12 @@ impl IfaceImpl {
}
}

dup_metadata.iter().for_each(|(field_name, &count)| {
if count > 1 {
dup_metadata
.iter()
.filter(|(_, &count)| count > 1)
.for_each(|(field_name, &count)| {
errors.push(ImplInconsistency::RepeatedMetaData(field_name.clone(), count));
}
});
});

Check warning on line 435 in src/interface/iimpl.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/iimpl.rs#L430-L435

Added lines #L430 - L435 were not covered by tests

for name in iface.global_state.keys() {
if self.global_state.iter().all(|field| &field.name != name) {
Expand All @@ -448,11 +449,12 @@ impl IfaceImpl {
}
}

dup_global_state.iter().for_each(|(field_name, &count)| {
if count > 1 {
dup_global_state
.iter()
.filter(|(_, &count)| count > 1)
.for_each(|(field_name, &count)| {
errors.push(ImplInconsistency::RepeatedGlobalState(field_name.clone(), count));
}
});
});

Check warning on line 457 in src/interface/iimpl.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/iimpl.rs#L452-L457

Added lines #L452 - L457 were not covered by tests

for name in iface.assignments.keys() {
if self.assignments.iter().all(|field| &field.name != name) {
Expand All @@ -470,11 +472,12 @@ impl IfaceImpl {
}
}

dup_assignments.iter().for_each(|(field_name, &count)| {
if count > 1 {
dup_assignments
.iter()
.filter(|(_, &count)| count > 1)
.for_each(|(field_name, &count)| {
errors.push(ImplInconsistency::RepeatedAssignments(field_name.clone(), count));
}
});
});

Check warning on line 480 in src/interface/iimpl.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/iimpl.rs#L475-L480

Added lines #L475 - L480 were not covered by tests

for name in iface.valencies.keys() {
if self.valencies.iter().all(|field| &field.name != name) {
Expand All @@ -491,11 +494,12 @@ impl IfaceImpl {
errors.push(ImplInconsistency::SchemaValencyAbsent(field.name.clone(), field.id));
}
}
dup_valencies.iter().for_each(|(field_name, &count)| {
if count > 1 {
dup_valencies
.iter()
.filter(|(_, &count)| count > 1)
.for_each(|(field_name, &count)| {
errors.push(ImplInconsistency::RepeatedValencies(field_name.clone(), count));
}
});
});

Check warning on line 502 in src/interface/iimpl.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/iimpl.rs#L497-L502

Added lines #L497 - L502 were not covered by tests

for name in iface.transitions.keys() {
if self.transitions.iter().all(|field| &field.name != name) {
Expand All @@ -514,11 +518,13 @@ impl IfaceImpl {
}
}

dup_transitions.iter().for_each(|(field_name, &count)| {
if count > 1 {
dup_transitions
.iter()
.filter(|(_, &count)| count > 1)
.for_each(|(field_name, &count)| {
errors.push(ImplInconsistency::RepeatedTransitions(field_name.clone(), count));
}
});
});

Check warning on line 526 in src/interface/iimpl.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/iimpl.rs#L521-L526

Added lines #L521 - L526 were not covered by tests

for name in iface.extensions.keys() {
if self.extensions.iter().all(|field| &field.name != name) {
errors.push(ImplInconsistency::IfaceExtensionAbsent(name.clone()));
Expand All @@ -535,11 +541,13 @@ impl IfaceImpl {
}
}

dup_extensions.iter().for_each(|(field_name, &count)| {
if count > 1 {
dup_extensions
.iter()
.filter(|(_, &count)| count > 1)
.for_each(|(field_name, &count)| {
errors.push(ImplInconsistency::RepeatedExtensions(field_name.clone(), count));
}
});
});

Check warning on line 549 in src/interface/iimpl.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/iimpl.rs#L544-L549

Added lines #L544 - L549 were not covered by tests

for var in &self.errors {
if iface.errors.keys().all(|name| name != &var.name) {
errors.push(ImplInconsistency::IfaceErrorAbsent(var.name.clone()));
Expand Down

0 comments on commit d7eac9a

Please sign in to comment.