Enum html_editor::Node
source · pub enum Node {
Element {
name: String,
attrs: Vec<(String, String)>,
children: Vec<Node>,
},
Text(String),
Comment(String),
Doctype(Doctype),
}Expand description
Node of DOM
Variants§
Implementations§
source§impl Node
impl Node
sourcepub fn is_element(&self) -> bool
pub fn is_element(&self) -> bool
Check if it is an element node.
use html_editor::Node;
assert_eq!(Node::new_element("div", vec![("id", "app")], vec![]).is_element(), true);
assert_eq!(Node::Text("Lorem Ipsum".to_string()).is_element(), false);sourcepub fn into_element(self) -> Element
pub fn into_element(self) -> Element
Convert the node into an element.
Warning: The program will panic if it fails to convert. So take care to use this method unless you are sure.
Example:
use html_editor::{Node, Element};
let a: Node = Node::new_element("div", vec![("id", "app")], vec![]);
let a: Element = a.into_element();
let b: Node = Node::Text("hello".to_string());
// The next line will panic at 'Text("hello") is not an element'
// let b: Element = a.into_element();Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
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