aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-10-21 03:31:21 -0500
committerGitHub <noreply@github.com>2017-10-21 03:31:21 -0500
commit2b03a9974c61d1481d4b40351ff1305ad0b26588 (patch)
treea9101c4f23bba203bea997c730edbe5a1783716a /components/script/dom/document.rs
parent48c715c1c86301d0f25e70d3e690d04d8303c58f (diff)
parent2d45e9d2da571e70deef137f9022de87cc1126f3 (diff)
downloadservo-2b03a9974c61d1481d4b40351ff1305ad0b26588.tar.gz
servo-2b03a9974c61d1481d4b40351ff1305ad0b26588.zip
Auto merge of #18968 - mbrubeck:try, r=emilio
Use try syntax for Option where appropriate - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they are refactoring only <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18968) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 3edd2fdc737..2601ea8f94e 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -2089,10 +2089,9 @@ fn get_registrable_domain_suffix_of_or_is_equal_to(host_suffix_string: &str, ori
};
// Step 4.2
- let (prefix, suffix) = match original_host.len().checked_sub(host.len()) {
- Some(index) => original_host.split_at(index),
- None => return None,
- };
+ let index = original_host.len().checked_sub(host.len())?;
+ let (prefix, suffix) = original_host.split_at(index);
+
if !prefix.ends_with(".") {
return None;
}
@@ -2336,11 +2335,7 @@ impl Document {
///
/// Also, shouldn't return an option, I'm quite sure.
pub fn device(&self) -> Option<Device> {
- let window_size = match self.window().window_size() {
- Some(ws) => ws,
- None => return None,
- };
-
+ let window_size = self.window().window_size()?;
let viewport_size = window_size.initial_viewport;
let device_pixel_ratio = window_size.device_pixel_ratio;
Some(Device::new(MediaType::screen(), viewport_size, device_pixel_ratio))
@@ -4034,12 +4029,9 @@ impl PendingInOrderScriptVec {
fn take_next_ready_to_be_executed(&self) -> Option<(DomRoot<HTMLScriptElement>, ScriptResult)> {
let mut scripts = self.scripts.borrow_mut();
- let pair = scripts.front_mut().and_then(PendingScript::take_result);
- if pair.is_none() {
- return None;
- }
+ let pair = scripts.front_mut()?.take_result()?;
scripts.pop_front();
- pair
+ Some(pair)
}
fn clear(&self) {