Skip to content

Commit 2334344

Browse files
folkertdevtgross35
authored andcommitted
fix an if statement that can be collapsed
1 parent f2918cd commit 2334344

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

crates/libm-macros/src/lib.rs

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(let_chains)]
2+
13
mod enums;
24
mod parse;
35
mod shared;
@@ -266,27 +268,27 @@ fn validate(input: &mut StructuredInput) -> syn::Result<Vec<&'static MathOpInfo>
266268
}
267269
}
268270

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-
}
271+
if let Some(map) = &input.fn_extra
272+
&& !map.keys().any(|key| key == "_")
273+
{
274+
// No default provided; make sure every expected function is covered
275+
let mut fns_not_covered = Vec::new();
276+
for func in &fn_list {
277+
if !map.keys().any(|key| key == func.name) {
278+
// `name` was not mentioned in the `match` statement
279+
fns_not_covered.push(func);
278280
}
281+
}
279282

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-
}
283+
if !fns_not_covered.is_empty() {
284+
let e = syn::Error::new(
285+
input.fn_extra_span.unwrap(),
286+
format!(
287+
"`fn_extra`: no default `_` pattern specified and the following \
288+
patterns are not covered: {fns_not_covered:#?}"
289+
),
290+
);
291+
return Err(e);
290292
}
291293
};
292294

0 commit comments

Comments
 (0)