pub struct Index { /* private fields */ }Expand description
Produces an index for each Element in the [`Document’]. Provides lookups for an element’s
parent. This requires ownership of the document and pins the document.
§Example
use exile::Document;
let xml = "<a><b/><c><d>x</d><e/></c></a>";
let doc = exile::parse(xml).unwrap();
// create an index consuming the document
let index = doc.index();
// get the element at index 3 (depth-first numbering).
let d = index.element(3).unwrap();
// get that element's parent
let c = index.parent(&d).unwrap();
// prove it!
assert_eq!("c", c.name());Implementations§
Source§impl Index
impl Index
Sourcepub fn into_doc(self) -> Document
pub fn into_doc(self) -> Document
Destroy the index and return ownership of the inner Document.
Sourcepub fn parent(&self, element: &Element) -> Option<&Element>
pub fn parent(&self, element: &Element) -> Option<&Element>
Gets the parent of the given element.
Sourcepub fn parent_index(&self, element: usize) -> Option<usize>
pub fn parent_index(&self, element: usize) -> Option<usize>
Gets the index of the parent of the element (which is given by index in this case).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Index
impl !RefUnwindSafe for Index
impl !Send for Index
impl !Sync for Index
impl Unpin for Index
impl UnwindSafe for Index
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