Skip to content

Commit ad4cea7

Browse files
committed
fix an if statement that can be collapsed
1 parent f2918cd commit ad4cea7

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

crates/libm-macros/src/lib.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -266,27 +266,28 @@ fn validate(input: &mut StructuredInput) -> syn::Result<Vec<&'static MathOpInfo>
266266
}
267267
}
268268

269-
if let Some(map) = &input.fn_extra {
270-
if !map.keys().any(|key| key == "_") {
271-
// No default provided; make sure every expected function is covered
272-
let mut fns_not_covered = Vec::new();
273-
for func in &fn_list {
274-
if !map.keys().any(|key| key == func.name) {
275-
// `name` was not mentioned in the `match` statement
276-
fns_not_covered.push(func);
277-
}
269+
if input
270+
.fn_extra
271+
.map_or_default(|map| !map.keys().any(|key| key == "_"))
272+
{
273+
// No default provided; make sure every expected function is covered
274+
let mut fns_not_covered = Vec::new();
275+
for func in &fn_list {
276+
if !map.keys().any(|key| key == func.name) {
277+
// `name` was not mentioned in the `match` statement
278+
fns_not_covered.push(func);
278279
}
280+
}
279281

280-
if !fns_not_covered.is_empty() {
281-
let e = syn::Error::new(
282-
input.fn_extra_span.unwrap(),
283-
format!(
284-
"`fn_extra`: no default `_` pattern specified and the following \
285-
patterns are not covered: {fns_not_covered:#?}"
286-
),
287-
);
288-
return Err(e);
289-
}
282+
if !fns_not_covered.is_empty() {
283+
let e = syn::Error::new(
284+
input.fn_extra_span.unwrap(),
285+
format!(
286+
"`fn_extra`: no default `_` pattern specified and the following \
287+
patterns are not covered: {fns_not_covered:#?}"
288+
),
289+
);
290+
return Err(e);
290291
}
291292
};
292293

0 commit comments

Comments
 (0)