From c3da0c225b72f3ebbd5443e00803a2f7da93a39b Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 26 Oct 2023 18:00:14 -0400 Subject: [PATCH] Make safer --- src/class.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/class.rs b/src/class.rs index 3d26bfb0..1240a046 100644 --- a/src/class.rs +++ b/src/class.rs @@ -268,14 +268,10 @@ pub fn class_to_class_def( match expr { Expr::Ident(ident) => Some(ident.sym.to_string()), Expr::Member(member_expr) => { - let prop = member_expr.to_owned().prop.ident().unwrap().sym.to_string(); - let obj = walk_class_extends(&member_expr.obj); + let prop = member_expr.prop.as_ident()?.sym.to_string(); + let mut string_path = walk_class_extends(&member_expr.obj)?; - obj.as_ref()?; - - let mut string_path = obj.unwrap(); - - string_path.push_str("."); + string_path.push('.'); string_path.push_str(&prop); Some(string_path)