From 23dba0218296a1e7848a4e31b78cbc5100282ec2 Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Fri, 29 Aug 2025 22:40:09 +0700 Subject: [PATCH] refactor: let-else in fn ast_from_text --- lib/src/make.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/src/make.rs b/lib/src/make.rs index 5c4f888..22e14eb 100644 --- a/lib/src/make.rs +++ b/lib/src/make.rs @@ -8,16 +8,15 @@ use rnix::{ fn ast_from_text(text: &str) -> N { let parse = rnix::parse(text); - match parse.node().descendants().find_map(N::cast) { - Some(it) => it, - None => { - panic!( - "Failed to make ast node `{}` from text `{}`", - std::any::type_name::(), - text - ) - } - } + let Some(node) = parse.node().descendants().find_map(N::cast) else { + panic!( + "Failed to make ast node `{}` from text `{}`", + std::any::type_name::(), + text + ); + }; + + node } pub fn parenthesize(node: &SyntaxNode) -> types::Paren { -- 2.51.2