pub struct Children<'a, 'b>(/* private fields */);Expand description
A thin wrapper around the children of HTMLTag
Implementations§
Source§impl<'a, 'b> Children<'a, 'b>
impl<'a, 'b> Children<'a, 'b>
Sourcepub fn top(&self) -> &RawChildren
pub fn top(&self) -> &RawChildren
Returns the topmost, direct children of this tag.
§Example
let dom = tl::parse(r#"
<div id="a">
<div id="b">
<span>Hello</span>
<span>World</span>
<span>.</span>
</div>
</div>
"#, Default::default()).unwrap();
let a = dom.get_element_by_id("a")
.unwrap()
.get(dom.parser())
.unwrap()
.as_tag()
.unwrap();
// Calling this function on the first div tag (#a) will return a slice containing 3 elements:
// - whitespaces around (before and after) div#b
// - div#b itself
// It does **not** contain the inner span tags
assert_eq!(a.children().top().len(), 3);Sourcepub fn start(&self) -> Option<InnerNodeHandle>
pub fn start(&self) -> Option<InnerNodeHandle>
Returns the starting boundary of the children of this tag.
Sourcepub fn end(&self, parser: &Parser<'a>) -> Option<InnerNodeHandle>
pub fn end(&self, parser: &Parser<'a>) -> Option<InnerNodeHandle>
Returns the ending boundary of the children of this tag.
Sourcepub fn boundaries(
&self,
parser: &Parser<'a>,
) -> Option<(InnerNodeHandle, InnerNodeHandle)>
pub fn boundaries( &self, parser: &Parser<'a>, ) -> Option<(InnerNodeHandle, InnerNodeHandle)>
Returns the (start, end) boundaries of the children of this tag.
Sourcepub fn all(&self, parser: &'b Parser<'a>) -> &'b [Node<'a>]
pub fn all(&self, parser: &'b Parser<'a>) -> &'b [Node<'a>]
Returns a slice containing all of the children of this HTMLTag,
including all subnodes of the children.
The difference between top() and all() is the same as VDom::children() and VDom::nodes()
§Example
let dom = tl::parse(r#"
<div id="a"><div id="b"><span>Hello</span><span>World</span><span>!</span></div></div>
"#, Default::default()).unwrap();
let a = dom.get_element_by_id("a")
.unwrap()
.get(dom.parser())
.unwrap()
.as_tag()
.unwrap();
// Calling this function on the first div tag (#a) will return a slice containing all of the subnodes:
// - div#b
// - span
// - Hello
// - span
// - World
// - span
// - !
assert_eq!(a.children().all(dom.parser()).len(), 7);Trait Implementations§
Auto Trait Implementations§
impl<'a, 'b> Freeze for Children<'a, 'b>
impl<'a, 'b> RefUnwindSafe for Children<'a, 'b>
impl<'a, 'b> !Send for Children<'a, 'b>
impl<'a, 'b> !Sync for Children<'a, 'b>
impl<'a, 'b> Unpin for Children<'a, 'b>
impl<'a, 'b> UnwindSafe for Children<'a, 'b>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more