From 567bba50465c54e9781dedfa656640768eb97184 Mon Sep 17 00:00:00 2001 From: laststylebender Date: Fri, 6 Sep 2024 00:16:45 +0530 Subject: [PATCH] - clean up --- src/cli/llm/infer_type_name.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/cli/llm/infer_type_name.rs b/src/cli/llm/infer_type_name.rs index 91ccd605f1..3d2007a49d 100644 --- a/src/cli/llm/infer_type_name.rs +++ b/src/cli/llm/infer_type_name.rs @@ -154,16 +154,13 @@ impl AsyncTransform for InferTypeName { async fn transform(&self, value: Self::Value) -> Valid { match self.generate(&value).await { - Ok(suggested_names) => { - match RenameTypes::new(suggested_names.iter()) - .transform(value) - .to_result() - { - Ok(v) => Valid::succeed(v), - Err(e) => Valid::fail(Error::Err(e.to_string())), - } - } - Err(err) => Valid::fail(err), + Ok(suggested_names) => RenameTypes::new(suggested_names.iter()) + .transform(value) + .to_result() + .map(Valid::succeed) + .map_err(|e| Error::Err(e.to_string())) + .unwrap_or_else(Valid::fail), + Err(e) => Valid::fail(e), } } }