changed match to 'matches!' (#31850)

This commit is contained in:
Aarya Khandelwal 2024-03-25 16:58:12 +05:30 committed by GitHub
parent 9a76dd9325
commit bd39e03eeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 185 additions and 229 deletions

View file

@ -206,12 +206,12 @@ pub enum FireMouseEventType {
impl FireMouseEventType {
pub fn as_str(&self) -> &str {
match self {
&FireMouseEventType::Move => "mousemove",
&FireMouseEventType::Over => "mouseover",
&FireMouseEventType::Out => "mouseout",
&FireMouseEventType::Enter => "mouseenter",
&FireMouseEventType::Leave => "mouseleave",
match *self {
FireMouseEventType::Move => "mousemove",
FireMouseEventType::Over => "mouseover",
FireMouseEventType::Out => "mouseout",
FireMouseEventType::Enter => "mouseenter",
FireMouseEventType::Leave => "mouseleave",
}
}
}
@ -2924,10 +2924,7 @@ impl Document {
}
fn is_character_value_key(key: &Key) -> bool {
match key {
Key::Character(_) | Key::Enter => true,
_ => false,
}
matches!(key, Key::Character(_) | Key::Enter)
}
#[derive(MallocSizeOf, PartialEq)]
@ -3055,10 +3052,7 @@ fn get_registrable_domain_suffix_of_or_is_equal_to(
/// <https://url.spec.whatwg.org/#network-scheme>
fn url_has_network_scheme(url: &ServoUrl) -> bool {
match url.scheme() {
"ftp" | "http" | "https" => true,
_ => false,
}
matches!(url.scheme(), "ftp" | "http" | "https")
}
#[derive(Clone, Copy, Eq, JSTraceable, MallocSizeOf, PartialEq)]
@ -3982,8 +3976,7 @@ impl Document {
impl Element {
fn click_event_filter_by_disabled_state(&self) -> bool {
let node = self.upcast::<Node>();
match node.type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(
matches!(node.type_id(), NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLButtonElement,
)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(
@ -3997,9 +3990,7 @@ impl Element {
)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLTextAreaElement,
)) if self.disabled_state() => true,
_ => false,
}
)) if self.disabled_state())
}
}
@ -4599,14 +4590,15 @@ impl DocumentMethods for Document {
self.get_html_element().and_then(|root| {
let node = root.upcast::<Node>();
node.children()
.find(|child| match child.type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLBodyElement,
)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLFrameSetElement,
)) => true,
_ => false,
.find(|child| {
matches!(
child.type_id(),
NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLBodyElement,
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLFrameSetElement,
))
)
})
.map(|node| DomRoot::downcast(node).unwrap())
})