tangled
alpha
login
or
join now
oppi.li
/
statix
0
fork
atom
Lints and suggestions for the Nix programming language
0
fork
atom
overview
issues
pulls
pipelines
refactor: let-else in fn ast_from_text
mightyiam.tngl.sh
7 months ago
23dba021
57b2dcd7
+9
-10
1 changed file
expand all
collapse all
unified
split
lib
src
make.rs
+9
-10
lib/src/make.rs
reviewed
···
8
8
fn ast_from_text<N: TypedNode>(text: &str) -> N {
9
9
let parse = rnix::parse(text);
10
10
11
11
-
match parse.node().descendants().find_map(N::cast) {
12
12
-
Some(it) => it,
13
13
-
None => {
14
14
-
panic!(
15
15
-
"Failed to make ast node `{}` from text `{}`",
16
16
-
std::any::type_name::<N>(),
17
17
-
text
18
18
-
)
19
19
-
}
20
20
-
}
11
11
+
let Some(node) = parse.node().descendants().find_map(N::cast) else {
12
12
+
panic!(
13
13
+
"Failed to make ast node `{}` from text `{}`",
14
14
+
std::any::type_name::<N>(),
15
15
+
text
16
16
+
);
17
17
+
};
18
18
+
19
19
+
node
21
20
}
22
21
23
22
pub fn parenthesize(node: &SyntaxNode) -> types::Paren {