Skip to content

Commit 1133944

Browse files
committed
let else was stablized in 1.65
1 parent a9a1c49 commit 1133944

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

packages/yew-macro/src/html_tree/html_for.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,22 @@ impl Parse for HtmlFor {
4343
braced!(body_stream in input);
4444

4545
let body = HtmlChildrenTree::parse_delimited(&body_stream)?;
46-
// TODO: reduce nesting by using if-let guards / let-else statements once MSRV is raised
46+
// TODO: more concise code by using if-let guards once MSRV is raised
4747
for child in body.0.iter() {
48-
if let HtmlTree::Element(element) = child {
49-
if let Some(key) = &element.props.special.key {
50-
if is_contextless_pure(&key.value) {
51-
return Err(syn::Error::new(
52-
key.value.span(),
53-
"duplicate key for a node in a `for`-loop\nthis will create elements \
48+
let HtmlTree::Element(element) = child else {
49+
continue;
50+
};
51+
52+
let Some(key) = &element.props.special.key else {
53+
continue;
54+
};
55+
56+
if is_contextless_pure(&key.value) {
57+
return Err(syn::Error::new(
58+
key.value.span(),
59+
"duplicate key for a node in a `for`-loop\nthis will create elements \
5460
with duplicate keys if the loop iterates more than once",
55-
));
56-
}
57-
}
61+
));
5862
}
5963
}
6064
Ok(Self { pat, iter, body })

0 commit comments

Comments
 (0)