From 6a28d62b15e8c9251e01f674faf342ee6bce1359 Mon Sep 17 00:00:00 2001 From: Brandon Fairchild Date: Tue, 17 Nov 2015 16:58:37 -0500 Subject: [PATCH 1/2] Make Node::is_parent_of more idiomatic --- components/script/dom/node.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 3db56ed3c1d..9c296ac4385 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -599,10 +599,7 @@ impl Node { } pub fn is_parent_of(&self, child: &Node) -> bool { - match child.parent_node.get() { - Some(ref parent) => parent.r() == self, - None => false, - } + child.parent_node.get().map_or(false, |ref parent| parent.r() == self) } pub fn to_trusted_node_address(&self) -> TrustedNodeAddress { From 7f75a881a42c9ca71cdf79547dcf04e326f9ecfe Mon Sep 17 00:00:00 2001 From: Brandon Fairchild Date: Tue, 17 Nov 2015 17:02:01 -0500 Subject: [PATCH 2/2] Make Stylesheet::is_effective_for_device more idiomatic --- components/style/stylesheets.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index 00e9def4900..c65706b27ce 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -148,10 +148,7 @@ impl Stylesheet { /// /// Always true if no associated MediaQueryList exists. pub fn is_effective_for_device(&self, device: &Device) -> bool { - match self.media { - Some(ref media) => media.evaluate(device), - None => true - } + self.media.as_ref().map_or(true, |ref media| media.evaluate(device)) } /// Return an iterator over all the rules within the style-sheet.