refactor(specctra/mesadata): more idiomatic Option handling

This commit is contained in:
Alain Emilia Anna Zscheile 2024-12-02 23:26:05 +01:00 committed by mikolaj
parent 5b7f4588a0
commit 3bd6a927b9
1 changed files with 6 additions and 9 deletions

View File

@ -119,8 +119,8 @@ impl SpecctraMesadata {
// workaround for differing syntax // workaround for differing syntax
// collapse multiple rule entries into a single one // collapse multiple rule entries into a single one
for rule in &pcb.structure.rules { for rule in &pcb.structure.rules {
if rule.width.is_some() { if let Some(width) = rule.width {
structure_rule.width = rule.width.unwrap() structure_rule.width = width
} }
structure_rule structure_rule
.clearances .clearances
@ -144,13 +144,10 @@ impl SpecctraMesadata {
/// it defaults to the general structure rule. /// it defaults to the general structure rule.
/// ///
pub fn get_rule(&self, net: usize) -> &SpecctraRule { pub fn get_rule(&self, net: usize) -> &SpecctraRule {
if let Some(netclass) = self.net_netclass.get(&net) { self.net_netclass
self.class_rules .get(&net)
.get(netclass) .and_then(|netclass| self.class_rules.get(netclass))
.unwrap_or(&self.structure_rule) .unwrap_or(&self.structure_rule)
} else {
&self.structure_rule
}
} }
} }