Lints and suggestions for the Nix programming language

refactor: let-else in fn ast_from_text

+9 -10
+9 -10
lib/src/make.rs
··· 8 8 fn ast_from_text<N: TypedNode>(text: &str) -> N { 9 9 let parse = rnix::parse(text); 10 10 11 - match parse.node().descendants().find_map(N::cast) { 12 - Some(it) => it, 13 - None => { 14 - panic!( 15 - "Failed to make ast node `{}` from text `{}`", 16 - std::any::type_name::<N>(), 17 - text 18 - ) 19 - } 20 - } 11 + let Some(node) = parse.node().descendants().find_map(N::cast) else { 12 + panic!( 13 + "Failed to make ast node `{}` from text `{}`", 14 + std::any::type_name::<N>(), 15 + text 16 + ); 17 + }; 18 + 19 + node 21 20 } 22 21 23 22 pub fn parenthesize(node: &SyntaxNode) -> types::Paren {