diff --git a/src/lib/js/array.rs b/src/lib/js/array.rs index 5cf3fff5f5..e8767636dd 100644 --- a/src/lib/js/array.rs +++ b/src/lib/js/array.rs @@ -255,8 +255,7 @@ pub fn unshift(this: &Value, args: &[Value], _: &mut Interpreter) -> ResultValue pub fn _create(global: &Value) -> Value { let array = to_value(make_array as NativeFunctionData); let proto = ValueData::new_obj(Some(global)); - let length = Property::default() - .get(to_value(get_array_length as NativeFunctionData)); + let length = Property::default().get(to_value(get_array_length as NativeFunctionData)); proto.set_prop_slice("length", length); let concat_func = to_value(concat as NativeFunctionData); diff --git a/src/lib/js/console.rs b/src/lib/js/console.rs index 39cd593de9..00bbd0ce24 100644 --- a/src/lib/js/console.rs +++ b/src/lib/js/console.rs @@ -31,9 +31,17 @@ fn log_string_from(x: Value) -> String { } ObjectKind::Array => { write!(s, "[").unwrap(); - let len: i32 = - from_value(v.borrow().properties.get("length").unwrap().value.clone().unwrap().clone()) - .unwrap(); + let len: i32 = from_value( + v.borrow() + .properties + .get("length") + .unwrap() + .value + .clone() + .unwrap() + .clone(), + ) + .unwrap(); for i in 0..len { // Introduce recursive call to stringify any objects // which are part of the Array @@ -64,7 +72,13 @@ fn log_string_from(x: Value) -> String { } // Introduce recursive call to stringify any objects // which are keys of the object - write!(s, "{}: {}", key, log_string_from(val.value.clone().unwrap().clone())).unwrap(); + write!( + s, + "{}: {}", + key, + log_string_from(val.value.clone().unwrap().clone()) + ) + .unwrap(); if key != last_key { write!(s, ", ").unwrap(); } diff --git a/src/lib/js/function.rs b/src/lib/js/function.rs index 2417ea4452..7737488530 100644 --- a/src/lib/js/function.rs +++ b/src/lib/js/function.rs @@ -73,7 +73,15 @@ impl Debug for NativeFunction { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{{")?; for (key, val) in self.object.properties.iter() { - write!(f, "{}: {}", key, val.value.as_ref().unwrap_or(&Gc::new(ValueData::Undefined)).clone())?; + write!( + f, + "{}: {}", + key, + val.value + .as_ref() + .unwrap_or(&Gc::new(ValueData::Undefined)) + .clone() + )?; } write!(f, "}}") } diff --git a/src/lib/js/object.rs b/src/lib/js/object.rs index ab5c7aaecb..5368d8051b 100644 --- a/src/lib/js/object.rs +++ b/src/lib/js/object.rs @@ -269,8 +269,8 @@ impl Object { // 5 if desc.is_generic_descriptor() { - - // 6 + + // 6 } else if current.is_data_descriptor() != desc.is_data_descriptor() { // a if !current.configurable.unwrap() { @@ -281,28 +281,33 @@ impl Object { // Convert to accessor current.value = None; current.writable = None; - - } else { // c + } else { + // c // convert to data current.get = None; current.set = None; } self.properties.insert(property_key, current); - // 7 + // 7 } else if current.is_data_descriptor() && desc.is_data_descriptor() { // a - if !current.configurable.unwrap()&& !current.writable.unwrap() { + if !current.configurable.unwrap() && !current.writable.unwrap() { if desc.writable.is_some() && desc.writable.unwrap() { return false; } - - if desc.value.is_some() && !same_value(&desc.value.clone().unwrap(), ¤t.value.clone().unwrap()) { + + if desc.value.is_some() + && !same_value( + &desc.value.clone().unwrap(), + ¤t.value.clone().unwrap(), + ) + { return false; } return true; } - // 8 + // 8 } else { } diff --git a/src/lib/js/regexp.rs b/src/lib/js/regexp.rs index f7f3295ac3..96a8efcbe7 100644 --- a/src/lib/js/regexp.rs +++ b/src/lib/js/regexp.rs @@ -181,8 +181,7 @@ fn get_unicode(this: &Value, _: &[Value], _: &mut Interpreter) -> ResultValue { } fn _make_prop(getter: NativeFunctionData) -> Property { - Property::default() - .get(to_value(getter)) + Property::default().get(to_value(getter)) } /// Search for a match between this regex and a specified string diff --git a/src/lib/js/string.rs b/src/lib/js/string.rs index 35339ce97b..1a478a16b6 100644 --- a/src/lib/js/string.rs +++ b/src/lib/js/string.rs @@ -525,8 +525,7 @@ pub fn trim_end(this: &Value, _: &[Value], ctx: &mut Interpreter) -> ResultValue pub fn _create(global: &Value) -> Value { let string = to_value(make_string as NativeFunctionData); let proto = ValueData::new_obj(Some(global)); - let prop = Property::default() - .get(to_value(get_string_length as NativeFunctionData)); + let prop = Property::default().get(to_value(get_string_length as NativeFunctionData)); proto.set_prop_slice("length", prop); proto.set_field_slice("charAt", to_value(char_at as NativeFunctionData)); diff --git a/src/lib/js/value.rs b/src/lib/js/value.rs index 5f3e3a941b..758374b397 100644 --- a/src/lib/js/value.rs +++ b/src/lib/js/value.rs @@ -291,7 +291,7 @@ impl ValueData { // If the Property has [[Get]] set to a function, we should run that and return the Value let prop_getter = match prop.get { Some(_) => None, - None => None + None => None, }; // If the getter is populated, use that. If not use [[Value]] instead @@ -478,9 +478,10 @@ impl ValueData { JSONValue::Array(vs) => { let mut new_obj = Object::default(); for (idx, json) in vs.iter().enumerate() { - new_obj - .properties - .insert(idx.to_string(), Property::default().value(to_value(json.clone()))); + new_obj.properties.insert( + idx.to_string(), + Property::default().value(to_value(json.clone())), + ); } new_obj.properties.insert( "length".to_string(), @@ -491,9 +492,10 @@ impl ValueData { JSONValue::Object(obj) => { let mut new_obj = Object::default(); for (key, json) in obj.iter() { - new_obj - .properties - .insert(key.clone(), Property::default().value(to_value(json.clone()))); + new_obj.properties.insert( + key.clone(), + Property::default().value(to_value(json.clone())), + ); } ValueData::Object(GcCell::new(new_obj)) @@ -562,7 +564,15 @@ impl Display for ValueData { // Print public properties if let Some((last_key, _)) = v.borrow().properties.iter().last() { for (key, val) in v.borrow().properties.iter() { - write!(f, "{}: {}", key, val.value.as_ref().unwrap_or(&Gc::new(ValueData::Undefined)).clone())?; + write!( + f, + "{}: {}", + key, + val.value + .as_ref() + .unwrap_or(&Gc::new(ValueData::Undefined)) + .clone() + )?; if key != last_key { write!(f, ", ")?; }