diff --git a/core/src/avm1/value.rs b/core/src/avm1/value.rs index b41257540..a67252ea6 100644 --- a/core/src/avm1/value.rs +++ b/core/src/avm1/value.rs @@ -103,33 +103,14 @@ unsafe impl<'gc> gc_arena::Collect for Value<'gc> { impl PartialEq for Value<'_> { fn eq(&self, other: &Self) -> bool { - match self { - Value::Undefined => match other { - Value::Undefined => true, - _ => false, - }, - Value::Null => match other { - Value::Null => true, - _ => false, - }, - Value::Bool(value) => match other { - Value::Bool(other_value) => value == other_value, - _ => false, - }, - Value::Number(value) => match other { - Value::Number(other_value) => { - (value == other_value) || (value.is_nan() && other_value.is_nan()) - } - _ => false, - }, - Value::String(value) => match other { - Value::String(other_value) => **value == **other_value, - _ => false, - }, - Value::Object(value) => match other { - Value::Object(other_value) => Object::ptr_eq(*value, *other_value), - _ => false, - }, + match (self, other) { + (Value::Undefined, Value::Undefined) => true, + (Value::Null, Value::Null) => true, + (Value::Bool(a), Value::Bool(b)) => a == b, + (Value::Number(a), Value::Number(b)) => (a == b) || (a.is_nan() && b.is_nan()), + (Value::String(a), Value::String(b)) => a == b, + (Value::Object(a), Value::Object(b)) => Object::ptr_eq(*a, *b), + _ => false, } } } diff --git a/core/src/avm2/names.rs b/core/src/avm2/names.rs index 6595dc66d..7c347b305 100644 --- a/core/src/avm2/names.rs +++ b/core/src/avm2/names.rs @@ -74,17 +74,11 @@ impl<'gc> Namespace<'gc> { } pub fn is_any(&self) -> bool { - match self { - Self::Any => true, - _ => false, - } + matches!(self, Self::Any) } pub fn is_private(&self) -> bool { - match self { - Self::Private(_) => true, - _ => false, - } + matches!(self, Self::Private(_)) } } diff --git a/core/src/avm2/script_object.rs b/core/src/avm2/script_object.rs index c306f9836..24e12599b 100644 --- a/core/src/avm2/script_object.rs +++ b/core/src/avm2/script_object.rs @@ -696,17 +696,17 @@ impl<'gc> ScriptObjectData<'gc> { } pub fn has_own_virtual_getter(&self, name: &QName<'gc>) -> bool { - match self.values.get(name) { - Some(Property::Virtual { get: Some(_), .. }) => true, - _ => false, - } + matches!( + self.values.get(name), + Some(Property::Virtual { get: Some(_), .. }) + ) } pub fn has_own_virtual_setter(&self, name: &QName<'gc>) -> bool { - match self.values.get(name) { - Some(Property::Virtual { set: Some(_), .. }) => true, - _ => false, - } + matches!( + self.values.get(name), + Some(Property::Virtual { set: Some(_), .. }) + ) } pub fn proto(&self) -> Option> { diff --git a/core/src/avm2/value.rs b/core/src/avm2/value.rs index 58498f9c6..e1f516c18 100644 --- a/core/src/avm2/value.rs +++ b/core/src/avm2/value.rs @@ -107,35 +107,15 @@ impl<'gc> From> for Value<'gc> { impl PartialEq for Value<'_> { fn eq(&self, other: &Self) -> bool { - match self { - Value::Undefined => match other { - Value::Undefined => true, - _ => false, - }, - Value::Null => match other { - Value::Null => true, - _ => false, - }, - Value::Bool(value) => match other { - Value::Bool(other_value) => value == other_value, - _ => false, - }, - Value::Number(value) => match other { - Value::Number(other_value) => value == other_value, - _ => false, - }, - Value::String(value) => match other { - Value::String(other_value) => value == other_value, - _ => false, - }, - Value::Object(value) => match other { - Value::Object(other_value) => Object::ptr_eq(*value, *other_value), - _ => false, - }, - Value::Namespace(ns) => match other { - Value::Namespace(other_ns) => ns == other_ns, - _ => false, - }, + match (self, other) { + (Value::Undefined, Value::Undefined) => true, + (Value::Null, Value::Null) => true, + (Value::Bool(a), Value::Bool(b)) => a == b, + (Value::Number(a), Value::Number(b)) => a == b, + (Value::String(a), Value::String(b)) => a == b, + (Value::Object(a), Value::Object(b)) => Object::ptr_eq(*a, *b), + (Value::Namespace(a), Value::Namespace(b)) => a == b, + _ => false, } } } diff --git a/core/src/display_object/movie_clip.rs b/core/src/display_object/movie_clip.rs index 441cad146..40e13e6e2 100644 --- a/core/src/display_object/movie_clip.rs +++ b/core/src/display_object/movie_clip.rs @@ -2269,11 +2269,7 @@ impl<'gc, 'a> MovieClip<'gc> { id, place_object.depth.into(), &place_object, - if let PlaceObjectAction::Replace(_) = place_object.action { - true - } else { - false - }, + matches!(place_object.action, PlaceObjectAction::Replace(_)), ) { child } else { @@ -2481,11 +2477,10 @@ impl GotoPlaceObject { #[inline] fn modifies_original_item(&self) -> bool { - if let swf::PlaceObjectAction::Replace(_) = &self.place_object.action { - true - } else { - false - } + matches!( + &self.place_object.action, + swf::PlaceObjectAction::Replace(_) + ) } #[inline] diff --git a/core/src/xml/tree.rs b/core/src/xml/tree.rs index 9ff8143e9..a15e51427 100644 --- a/core/src/xml/tree.rs +++ b/core/src/xml/tree.rs @@ -793,10 +793,7 @@ impl<'gc> XMLNode<'gc> { /// Document roots and elements can yield children, while all other /// elements are structurally prohibited from adopting child `XMLNode`s. pub fn has_children(self) -> bool { - match &*self.0.read() { - XMLNodeData::Element { .. } | XMLNodeData::DocumentRoot { .. } => true, - _ => false, - } + matches!(*self.0.read(), XMLNodeData::Element { .. } | XMLNodeData::DocumentRoot { .. }) } /// Returns an iterator that yields child nodes. @@ -937,43 +934,28 @@ impl<'gc> XMLNode<'gc> { /// Check if this XML node constitutes the root of a whole document. pub fn is_document_root(self) -> bool { - match &*self.0.read() { - XMLNodeData::DocumentRoot { .. } => true, - _ => false, - } + matches!(*self.0.read(), XMLNodeData::DocumentRoot { .. }) } /// Check if this XML node constitutes an element. pub fn is_element(self) -> bool { - match &*self.0.read() { - XMLNodeData::Element { .. } => true, - _ => false, - } + matches!(*self.0.read(), XMLNodeData::Element { .. }) } /// Check if this XML node constitutes text. pub fn is_text(self) -> bool { - match &*self.0.read() { - XMLNodeData::Text { .. } => true, - _ => false, - } + matches!(*self.0.read(), XMLNodeData::Text { .. }) } /// Check if this XML node constitutes text. #[allow(dead_code)] pub fn is_comment(self) -> bool { - match &*self.0.read() { - XMLNodeData::Comment { .. } => true, - _ => false, - } + matches!(*self.0.read(), XMLNodeData::Comment { .. }) } /// Check if this XML node constitutes a DOCTYPE declaration pub fn is_doctype(self) -> bool { - match &*self.0.read() { - XMLNodeData::DocType { .. } => true, - _ => false, - } + matches!(*self.0.read(), XMLNodeData::DocType { .. }) } /// Create a duplicate copy of this node.