chore: Use matches!(...) in more places

This commit is contained in:
relrelb 2021-03-30 23:18:18 +03:00 committed by Mike Welsh
parent 9dc63a7831
commit 0f8f0986e9
4 changed files with 8 additions and 34 deletions

View File

@ -105,10 +105,7 @@ impl<'gc> Property<'gc> {
} }
pub fn is_virtual(&self) -> bool { pub fn is_virtual(&self) -> bool {
match self { matches!(self, Property::Virtual { .. })
Property::Virtual { .. } => true,
Property::Stored { .. } => false,
}
} }
} }

View File

@ -812,19 +812,11 @@ impl<'gc> LayoutBox<'gc> {
} }
pub fn is_text_box(&self) -> bool { pub fn is_text_box(&self) -> bool {
match &self.content { matches!(&self.content, LayoutContent::Text { .. })
LayoutContent::Text { .. } => true,
LayoutContent::Bullet { .. } => false,
LayoutContent::Drawing(..) => false,
}
} }
pub fn is_bullet(&self) -> bool { pub fn is_bullet(&self) -> bool {
match &self.content { matches!(&self.content, LayoutContent::Bullet { .. })
LayoutContent::Text { .. } => false,
LayoutContent::Bullet { .. } => true,
LayoutContent::Drawing(..) => false,
}
} }
/// Construct a duplicate layout box structure. /// Construct a duplicate layout box structure.

View File

@ -121,10 +121,7 @@ pub enum AvmObject<'gc> {
impl<'gc> AvmObject<'gc> { impl<'gc> AvmObject<'gc> {
/// Determine if this object is an AVM1 object. /// Determine if this object is an AVM1 object.
pub fn is_avm1_object(&self) -> bool { pub fn is_avm1_object(&self) -> bool {
match self { matches!(self, Self::Avm1(_))
Self::Avm1(_) => true,
Self::Avm2(_) => false,
}
} }
/// Attempt to access the AVM1 claim to this object, generating an error if /// Attempt to access the AVM1 claim to this object, generating an error if
@ -138,10 +135,7 @@ impl<'gc> AvmObject<'gc> {
/// Determine if this object is an AVM2 object. /// Determine if this object is an AVM2 object.
pub fn is_avm2_object(&self) -> bool { pub fn is_avm2_object(&self) -> bool {
match self { matches!(self, Self::Avm2(_))
Self::Avm1(_) => false,
Self::Avm2(_) => true,
}
} }
/// Attempt to access the AVM2 claim to this object, generating an error if /// Attempt to access the AVM2 claim to this object, generating an error if

View File

@ -83,26 +83,17 @@ impl<'gc> Step<'gc> {
/// Yields true if this step entered an element. /// Yields true if this step entered an element.
pub fn stepped_in(self) -> bool { pub fn stepped_in(self) -> bool {
match self { matches!(self, Self::In(_))
Self::In(_) => true,
Self::Around(_) | Self::Out(_) => false,
}
} }
/// Yields true if this step encountered a non-element node. /// Yields true if this step encountered a non-element node.
pub fn stepped_around(self) -> bool { pub fn stepped_around(self) -> bool {
match self { matches!(self, Self::Around(_))
Self::Around(_) => true,
Self::In(_) | Self::Out(_) => false,
}
} }
/// Yields true if this step exited an element. /// Yields true if this step exited an element.
pub fn stepped_out(self) -> bool { pub fn stepped_out(self) -> bool {
match self { matches!(self, Self::Out(_))
Self::Out(_) => true,
Self::Around(_) | Self::In(_) => false,
}
} }
} }