diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-10-21 03:31:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-21 03:31:21 -0500 |
commit | 2b03a9974c61d1481d4b40351ff1305ad0b26588 (patch) | |
tree | a9101c4f23bba203bea997c730edbe5a1783716a /components/script/dom/node.rs | |
parent | 48c715c1c86301d0f25e70d3e690d04d8303c58f (diff) | |
parent | 2d45e9d2da571e70deef137f9022de87cc1126f3 (diff) | |
download | servo-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/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 0186d9e6a67..7f7d9bb91dd 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1206,11 +1206,7 @@ pub struct FollowingNodeIterator { impl FollowingNodeIterator { /// Skips iterating the children of the current node pub fn next_skipping_children(&mut self) -> Option<DomRoot<Node>> { - let current = match self.current.take() { - None => return None, - Some(current) => current, - }; - + let current = self.current.take()?; self.next_skipping_children_impl(current) } @@ -1244,10 +1240,7 @@ impl Iterator for FollowingNodeIterator { // https://dom.spec.whatwg.org/#concept-tree-following fn next(&mut self) -> Option<DomRoot<Node>> { - let current = match self.current.take() { - None => return None, - Some(current) => current, - }; + let current = self.current.take()?; if let Some(first_child) = current.GetFirstChild() { self.current = Some(first_child); @@ -1268,10 +1261,7 @@ impl Iterator for PrecedingNodeIterator { // https://dom.spec.whatwg.org/#concept-tree-preceding fn next(&mut self) -> Option<DomRoot<Node>> { - let current = match self.current.take() { - None => return None, - Some(current) => current, - }; + let current = self.current.take()?; self.current = if self.root == current { None @@ -1323,10 +1313,7 @@ impl TreeIterator { } pub fn next_skipping_children(&mut self) -> Option<DomRoot<Node>> { - let current = match self.current.take() { - None => return None, - Some(current) => current, - }; + let current = self.current.take()?; self.next_skipping_children_impl(current) } @@ -1353,10 +1340,7 @@ impl Iterator for TreeIterator { // https://dom.spec.whatwg.org/#concept-tree-order fn next(&mut self) -> Option<DomRoot<Node>> { - let current = match self.current.take() { - None => return None, - Some(current) => current, - }; + let current = self.current.take()?; if let Some(first_child) = current.GetFirstChild() { self.current = Some(first_child); self.depth += 1; |