mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Auto merge of #12854 - nox:impl-trait, r=jdm
Use impl Trait syntax for Node::child_elements <!-- 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/12854) <!-- Reviewable:end -->
This commit is contained in:
commit
27d082e577
2 changed files with 6 additions and 9 deletions
|
@ -70,7 +70,7 @@ use std::borrow::ToOwned;
|
||||||
use std::cell::{Cell, UnsafeCell};
|
use std::cell::{Cell, UnsafeCell};
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::iter::{self, FilterMap, Peekable};
|
use std::iter;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use string_cache::{Atom, Namespace, QualName};
|
use string_cache::{Atom, Namespace, QualName};
|
||||||
|
@ -781,7 +781,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn child_elements(&self) -> ChildElementIterator {
|
pub fn child_elements(&self) -> impl Iterator<Item=Root<Element>> {
|
||||||
self.children().filter_map(Root::downcast as fn(_) -> _).peekable()
|
self.children().filter_map(Root::downcast as fn(_) -> _).peekable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1111,10 +1111,6 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
|
||||||
// Iteration and traversal
|
// Iteration and traversal
|
||||||
//
|
//
|
||||||
|
|
||||||
pub type ChildElementIterator =
|
|
||||||
Peekable<FilterMap<NodeSiblingIterator,
|
|
||||||
fn(Root<Node>) -> Option<Root<Element>>>>;
|
|
||||||
|
|
||||||
pub struct NodeSiblingIterator {
|
pub struct NodeSiblingIterator {
|
||||||
current: Option<Root<Node>>,
|
current: Option<Root<Node>>,
|
||||||
}
|
}
|
||||||
|
@ -1460,7 +1456,7 @@ impl Node {
|
||||||
0 => (),
|
0 => (),
|
||||||
// Step 6.1.2
|
// Step 6.1.2
|
||||||
1 => {
|
1 => {
|
||||||
if !parent.child_elements().peek().is_none() {
|
if !parent.child_elements().next().is_none() {
|
||||||
return Err(Error::HierarchyRequest);
|
return Err(Error::HierarchyRequest);
|
||||||
}
|
}
|
||||||
if let Some(child) = child {
|
if let Some(child) = child {
|
||||||
|
@ -1476,7 +1472,7 @@ impl Node {
|
||||||
},
|
},
|
||||||
// Step 6.2
|
// Step 6.2
|
||||||
NodeTypeId::Element(_) => {
|
NodeTypeId::Element(_) => {
|
||||||
if !parent.child_elements().peek().is_none() {
|
if !parent.child_elements().next().is_none() {
|
||||||
return Err(Error::HierarchyRequest);
|
return Err(Error::HierarchyRequest);
|
||||||
}
|
}
|
||||||
if let Some(ref child) = child {
|
if let Some(ref child) = child {
|
||||||
|
@ -1503,7 +1499,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
if !parent.child_elements().peek().is_none() {
|
if !parent.child_elements().next().is_none() {
|
||||||
return Err(Error::HierarchyRequest);
|
return Err(Error::HierarchyRequest);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#![feature(as_unsafe_cell)]
|
#![feature(as_unsafe_cell)]
|
||||||
#![feature(borrow_state)]
|
#![feature(borrow_state)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
#![feature(conservative_impl_trait)]
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(custom_attribute)]
|
#![feature(custom_attribute)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue