chore: Use matches! to fix clippy lint
This commit is contained in:
parent
938a129a49
commit
e5480ee9b2
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(_))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Object<'gc>> {
|
||||
|
|
|
@ -107,35 +107,15 @@ impl<'gc> From<Namespace<'gc>> 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue