Skip to content

Commit a5f1984

Browse files
author
robert masen
committed
better matching
1 parent 668921d commit a5f1984

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

crates/backend/src/ast.rs

+21-19
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,16 @@ impl Program {
150150
let comments: Vec<String> = f.attrs
151151
.iter()
152152
.filter_map(|a| {
153-
if a.style == AttrStyle::Outer {
154-
Some(
155-
a.tts.clone().into_iter().filter_map(|t| match t {
156-
TokenTree::Literal(lit) => Some(format!("{}", lit)),
157-
_ => None,
158-
})
159-
)
160-
} else {
161-
None
153+
match a.style {
154+
AttrStyle::Outer => {
155+
Some(
156+
a.tts.clone().into_iter().filter_map(|t| match t {
157+
TokenTree::Literal(lit) => Some(format!("{}", lit)),
158+
_ => None,
159+
})
160+
)
161+
},
162+
_ => None,
162163
}
163164
})
164165
.fold(vec![], |mut acc, a| {acc.extend(a); acc});
@@ -1103,16 +1104,17 @@ fn extract_doc_comments(attrs: &Vec<syn::Attribute>) -> Vec<String> {
11031104
.iter()
11041105
.filter_map(|a| {
11051106
//We only care about outer comments for now
1106-
if a.style == AttrStyle::Outer {
1107-
//We only care about literal values
1108-
Some(
1109-
a.tts.clone().into_iter().filter_map(|t| match t {
1110-
TokenTree::Literal(lit) => Some(lit.to_string()),
1111-
_ => None,
1112-
})
1113-
)
1114-
} else {
1115-
None
1107+
match a.style {
1108+
AttrStyle::Outer => {
1109+
//We only care about literal values
1110+
Some(
1111+
a.tts.clone().into_iter().filter_map(|t| match t {
1112+
TokenTree::Literal(lit) => Some(lit.to_string()),
1113+
_ => None,
1114+
})
1115+
)
1116+
},
1117+
_ => None
11161118
}
11171119
})
11181120
//Fold up the [[String]] iter we created into Vec<String>

0 commit comments

Comments
 (0)